janvladimirmostert
01/08/2021, 3:53 PMvar i = 0
val map = mutableMapOf<String, Int>()
(1..10).forEach {
map["${++i}"] = ++i + i++
}
println(map)
{1=4, 4=10, 7=16, 10=22, 13=28, 16=34, 19=40, 22=46, 25=52, 28=58}
To ask it differently, is the IR being generated always such that map[...] evaluates first, then the ++i and then the i++ ?Vampire
01/08/2021, 3:58 PMNir
01/08/2021, 4:00 PMjanvladimirmostert
01/08/2021, 4:07 PMNir
01/08/2021, 4:08 PMVampire
01/08/2021, 4:08 PMNir
01/08/2021, 4:09 PMVampire
01/08/2021, 4:10 PMNir
01/08/2021, 4:10 PMAnimesh Sahu
01/09/2021, 6:51 AMI'm actually shocked that kotlin supports both ++i and i++Kotlin even has unary operator (like +i -i) 😛