why is transform in Map.mapValues defined as `tran...
# announcements
d
why is transform in Map.mapValues defined as
transform: (Map.Entry<K, V>) -> R
instead of just
transform: (V) -> R
?
And I don't have any objections here.. it's just not what I expected 🙂
v
I guess because you might want to calculate the new value based on the key and not only on the value
d
I guess that's because you might want to map values based on keys.
v
too late 😛
d
For mapping values you can do
.values.map()
Aawwwwww
v
But that wouldn't put the new values in the map
d
but
.values.map()
will return
List<R>
and not the initial map 😉
v
argh, too slow
d
but what you said makes sense, thanks 😉
K 1
n
fwiw I'm routinely confused by that design choice too, but it kinda makes sense.