so basically !!
# announcements
b
so basically !!
p
You can write
map.getValue(key)
b
perfect, thank you!
c
I'd do this:
(1..10).asSequence().mapNotNull { map[it] }
where
(1..10).asSequence()
is an example sequence of prospective keys, as I don't know what's your sequence like, and
map
is your map.
b
yeah I’m mapping over a different list and join elements from a map into it
kinda like a zip() function but with a more complex way to combine them than an index
c
basically, use
mapNotNull(map::get)
instead of
filter(map::containsKey)
.
Pavlo's suggestion will throw if the map doesn't have an entry with the specified key, unless the map has default provider