Is there way of getting the whole entry set back f...
# getting-started
m
Is there way of getting the whole entry set back from a map rather than just the value?
d
m
Yes, but how do I select an entry using a key?
n
map.entries.find { (k, v) -> k == key }
d
map[k]?.let { v -> k to v }
That gives you a
Pair<K, V>
and is much faster than searching through the whole set
m
what does the function
v -> k to v
do?
d
a to b
creates a
Pair
from a and b
m
k
is then unresolved?
n
k
would be the key that you request the entry for, kinda need to know it
m
Intellij is complaining that
k
is unresolved in
map[myKey].let { v  -> k to v }
n
in that case you want to do
map[myKey].let { v  -> myKey to v }