e.g. `map.getOrPut(key, { mutableSetOf() }).plusAs...
# getting-started
a
e.g.
map.getOrPut(key, { mutableSetOf() }).plusAssign(value)
❤️ 1
d
how is getOrPut different from computeIfAbsent
a
which type has
computeIfAbsent
?
d
map
a
Map in the stdlib doesn't have that function, so I suspect you mean the kotlinx.support-library that provides extensions for Kotlin 1.0?
d
MutableMap has it
Copy code
@Test
fun stuff() {
    val map = mutableMapOf<Int, Int>()
    val absent = map.computeIfAbsent(0, { 5 })

    print(absent) // 5
}
It’s a java function
a
oh right. From the documentation it seems like its the same