hey really rookie question. If i have a mutable ma...
# getting-started
v
hey really rookie question. If i have a mutable map = {3=0, 4=0, 5=0, 6=0, 7=1, 8=1, 9=1, 10=1, 11=2} . If I'm trying to get the max value in this --map.maxBy{it.value} . It returns a value 11=2. What type is this and how do I get the value "2" from it? -> https://leetcode.com/playground/eQrqK2Ug
1
w
Hey @Varun, it would be of type
Map.Entry<Int, Int>
You can access by the properties
key
and `value`:
Copy code
println(maxi.key) // 11
        println(maxi.value) // 2
v
Hey @wbertan thanks! I swear i tried that 10 times... but somehow works now :S
Line 5: Char 17: error: unresolved reference: value println(maxi.value)
did you change anything in that leetcode thing?
w
Nope, copied your code into Android Studio to see
a
or you can use
cache.values.max()
if you don’t care about the keys at all
v
thanks @araqnid