He started playing on the weekend with Kotlin and tried to get cards that work with operators. Somehow, Kotlin tells me that I am confusing him with ambiguity.
Here is the code that works (syntactically not the way I want):
var columns = sortedMapOf("a" to 1, "b" to 2)
columns.plusAssign("c" to 3)
And here is a code that just doesn't compile (but is syntactically closer to what I want)
var cs = sortedMapOf(1 to "a", 2 to "b")
cs += Pair(3, "c")
What short operational magic / casting am I missing?
Thanks in advance.
source
share