dMusicb
11/30/2018, 6:25 PMcompletedAlert?.let { updatedAlerts += it }
// or
if (completedAlert != null) updatedAlerts += completedAlert
Spike Baylor
11/30/2018, 6:51 PMnotNull
that was functionally the same as let, but that would at least describe what is going on.christophsturm
11/30/2018, 7:11 PMSpike Baylor
11/30/2018, 7:15 PMchristophsturm
11/30/2018, 7:15 PMupdatedAlerts+=(completedAlert ?: 0)
hudsonb
11/30/2018, 7:24 PMupdatedAlerts
is an Int
christophsturm
11/30/2018, 7:30 PMMike
11/30/2018, 9:55 PMdewildte
11/30/2018, 10:32 PMSpike Baylor
11/30/2018, 10:37 PMDaniel Tam
12/01/2018, 6:16 AMif
is not used to check nullability in Kotlin so your brain/eyes won't be able to skim the code as quickly as it breaks the common patterngildor
12/03/2018, 5:24 AMupdatedAlerts += (completedAlert ?: 0)
let is not help in this use case
Even better to make completedAlert
non-nullableDmitry Kandalov
12/06/2018, 9:02 AMif
expression, I’d write a ifNotNull
wrapper function around ?.let
.Pavlo Liapota
12/09/2018, 6:22 PMcompletedAlert
non-nullable.
Maybe something like that?
val completedAlert = getAlert() ?: return
updatedAlerts += completedAlert
You can extract this in separate function.ursus
12/13/2018, 3:05 PMandrewg
12/17/2018, 2:41 AMursus
12/17/2018, 4:46 AM