, but is it really on the bytecode level? Doesn't range expression generate an additional range object?
e
ephemient
08/10/2020, 8:43 AM
nope, you can dump the bytecode and check for yourself
l
Lars Wenning
08/10/2020, 8:47 AM
You can check the Bytecode via "Tools" -> "Kotlin" -> "Show Kotlin Bytecode" in IntelliJ.
This will open a window containing the Bytecode. From there you may already see what happened. You could click on "Decompile" and it will show you some Java Class created out of that Bytecode, containing an ordinary for loop (with no additional range objects or the like)
the for-in range is what's called "intrinsic", meaning it does compile directly to bytecode without an object allocation. FWIW, it was relatively recent...I'm having trouble finding it now, but I think it was in 1.3.* somewhere.