Hi, why does not work this? ```val pair = Pair(1,"...
# getting-started
z
Hi, why does not work this?
Copy code
val pair = Pair(1,"xxx")
map.put(*pair)
w
@zucen.co Is this not working for you?
Copy code
val map: Map<Int, String> = mapOf()
        val pair: Pair<Int, String> = Pair(1, "xxx")
        val newMap1 = map.plus(pair)
        val newMap2 = map + pair
Or when using mutable map have the
putAll
which accepts a list of pairs:
Copy code
val mutableMap: MutableMap<Int, String> = mutableMapOf()
        mutableMap.putAll(listOf(pair))
🙏 1
👌 1
o
what is that star?
what were you trying to achieve with it?
spread?
w
@oday I believe he were trying to "destructure" the pair and give to the arguments of the
map.put
which I believe were
Int
and
String
, respectively.
o
destructuring ok
👍 1