https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
d

Devanshu Vaidya

02/22/2024, 7:27 PM
Hi All, i want to know which type of map initialisation is mostly preferred 1.
map[key] = map.getOrPut(key){ defaultValue} + someOperation
2.
map[key] = map[key]?.let{ it -> someOperation} ?: defaultValue
3.
if(!map.contains(key)) { map.put(key, value) }
c

CLOVIS

02/23/2024, 4:13 PM
What is
someOperation
? Where did it go in the last one?
d

Devanshu Vaidya

02/23/2024, 4:25 PM
someOperations is more like adding or subtracting and in last one code is incomplete.
a

Adam S

02/24/2024, 11:56 AM
hi @Devanshu Vaidya, this channel is for Kotlin Native, but your question looks like a general Kotlin question. You might get more help in #getting-started.
d

Devanshu Vaidya

02/24/2024, 11:59 AM
Hey @Adam S, thanks for letting me know