https://kotlinlang.org logo
#announcements
Title
# announcements
l

LeoColman

08/20/2019, 10:07 PM
Doing
nullable?.let { list + it } ?: list
s

Shawn

08/20/2019, 10:18 PM
I mean, you could do
nullable?.let(list::add)
👍 1
or, keep it simple w/ an
if (nullable != null)
assuming mutablelist
are you reassigning or building a new read-only list or
d

Daniel

08/20/2019, 10:29 PM
Seems like a good place for a guard case if (nullable == null) return The other stuff seems to only needlessly complicate things.
l

LeoColman

08/20/2019, 11:02 PM
Those are better
I guess sometimes we go for the most complicated version 😅
d

David Glasser

08/21/2019, 4:59 AM
list + (nullable ?: listOf())
r

Ruckus

08/21/2019, 1:35 PM
@David Glasser That won't work unless
nullable
is a list.
3 Views