is there a simpler way to write something like: `...
# getting-started
d
is there a simpler way to write something like:
Copy code
val urlIds = ArrayList<Long?>

for (u in urls) {
  urlIds.add(u.id)
}
p
I'd suggest
Copy code
val urlIds = urls.map { it.id }
9
👍 1
d
@Patrick Louis thank you so much!
👍 1
t
If you want to avoid the nullable Long type in the result, you could also use
mapNotNull
, which will automatically discard the
null
values and make the generic parameter in your response non-null
👍🏽 2