I wanted to create a nested HashMap with default v...
# getting-started
j
I wanted to create a nested HashMap with default values. My attempt was:
val map = HashMap<String, HashMap<String, Int>>().withDefault { HashMap<String, Int>().withDefault{ 0 } }
but the outer map's withDefault shows error "Cannot infer type parameter V". I found a better solution using
HashMap<Pair<String, String>, Int>().withDefault{ 0 }
, but I'd like to know if my first approach is possible and why what I tried doesn't work.