Uberunix
08/27/2025, 12:39 AMYoussef Shoaib [MOD]
08/27/2025, 1:44 AMmap["foo"]
) is for runtime keys, while properties are known at compile time.Uberunix
08/27/2025, 2:21 AMKirill Grouchnikov
08/27/2025, 2:31 AMarray.index
? Like array.0
and array.1
? And then array.i
inside the loop? And then how would you express it if it's a more complex computation? It'll just get messy if you have to split array[functionCall(a,b,c)]
into a separate local variable to use the dot notation - for no good reason.Uberunix
08/27/2025, 2:35 AMYoussef Shoaib [MOD]
08/27/2025, 2:44 AMKirill Grouchnikov
08/27/2025, 2:44 AMYoussef Shoaib [MOD]
08/27/2025, 2:46 AMKirill Grouchnikov
08/27/2025, 2:47 AMUberunix
08/27/2025, 2:51 AMCLOVIS
08/28/2025, 8:43 AMclass Foo(val a: Map<String, Any?>) {
val banana: Int by a
}
val foo = Foo(mapOf("banana" to 5))
println(foo.a["banana"]) // 5
println(foo.banana) // 5
https://kt.academy/article/ak-map-delegateloke
08/29/2025, 9:18 AM