Daniele B
09/22/2020, 7:26 PMchanged
twice ?
val changed = changeSelectedCounty()
if (changed) {
showDetail()
}
I am looking for something like this, but it’s not accepted:
if (val changed = changeSelectedCounty()) {
showDetail()
}
I would to assign the result to the changed
variable, as it gives more claritynanodeath
09/22/2020, 7:40 PMchangeSelectedCounty().takeIf { changed -> changed }?.let { showDetail() }
but that's almost certainly confusingnanodeath
09/22/2020, 7:41 PMif (changeSelectedCounty() == CHANGE_OCCURRED) { showDetail() }
but...might be overkillnanodeath
09/22/2020, 7:41 PMDaniele B
09/22/2020, 7:45 PMCedrick Cooke
09/22/2020, 7:52 PMwhen (val changed = changeSelectedCounty()) {
true -> showDetail()
}
Brian Dilley
09/22/2020, 8:31 PMchangeSelectedCounty() ?: showDetail()
Brian Dilley
09/22/2020, 8:31 PMnanodeath
09/22/2020, 8:36 PMshowDetail
if changed
is nullitbhp
09/23/2020, 3:58 AMAkindele Beulah
09/23/2020, 10:39 AMitbhp
09/23/2020, 10:55 AMitbhp
09/23/2020, 10:55 AMBrian Dilley
09/23/2020, 6:29 PMBrian Dilley
09/23/2020, 6:29 PMval changed = if (changeSelectedCountry()) { true } else { false }
nanodeath
09/23/2020, 6:36 PM