zucen.co
03/01/2019, 10:14 AMval pair = Pair(1,"xxx")
map.put(*pair)
wbertan
03/01/2019, 10:35 AMval 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:
val mutableMap: MutableMap<Int, String> = mutableMapOf()
mutableMap.putAll(listOf(pair))
oday
03/01/2019, 12:49 PModay
03/01/2019, 12:49 PModay
03/01/2019, 12:49 PMwbertan
03/01/2019, 1:31 PMmap.put
which I believe were Int
and String
, respectively.oday
03/01/2019, 1:34 PM