y
03/24/2025, 12:39 PM&mut
to a map value? something like
fun getTarget(where: Where) {
val targetMap = if (foo) { this.map1 } else { this.map2 }
return targetMap[where]
}
// then used as something like
getTarget(somewhere) = "hello"
ephemient
03/24/2025, 1:30 PMKlitos Kyriacou
03/24/2025, 2:15 PMfun getTarget() =
if (foo) { this.map1 } else { this.map2 }
// then used as something like
getTarget()[somewhere] = "hello"
which is not really equivalent. Kotlin, like Java, doesn't have the concept of "LHS" types (such as C++'s or Rust's mutable references).Pearce Keesling
03/24/2025, 2:51 PMy
03/24/2025, 3:17 PM