robin
03/15/2017, 3:40 PMvar x = 0
repeat(10) { x += 1 }
After this code block, x
will be 10
.
If the code behaved like you seem to be expecting, x
would still be 0
after the block, which negates all the benefits you get by having real closures.