@Rob Elliot but then even if the list is empty it will try to map, right?
r
Rob Elliot
05/05/2021, 5:21 PM
Hmm - interesting, I’d assumed
List<T>.map
would have an
if empty return this
or perhaps an
if empty return emptyList()
, which always returns the same
object
, as an optimisation. But looks like it instantiates a new list instance regardless. Generally I prefer to get away from null as soon as possible, but perhaps in this case that’s bad advice.
👍 1
p
Pablo
05/05/2021, 5:24 PM
Yes, I did it like this because I thought that checking the null or empty it will avoid the