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

joshua.ewer

12/06/2017, 7:19 PM
anyone have a good idiom for solving this problem?
given two nullable lists,
a: List<String>?
and
b:List<String>?
if any are not null, return a concat list
else return null
g

gildor

12/07/2017, 1:23 AM
Also
Copy code
(b.orEmpty() + a.orEmpty()).takeIf { it.isNotEmpty() }
But little bit less efficient if both lists are null because will be created a new collection