is there a better kotlin form of this java-ish cod...
# getting-started
s
is there a better kotlin form of this java-ish code? operations is a mutablemap
Copy code
val opList = operations.computeIfAbsent(
    basePath
) { key: String? -> ArrayList() }
c
map.getOrPut(key) { value }
is the Kotlin version of that function, which is available on non-JVM targets, too (unlike
computeIfAbsent
)
e
note that
getOrPut
has different locking guarantees than
computeIfAbsent
, if that matters to you
s
thank you