Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-beta-2
-
None
Description
class Tester {
static main(args) {
c = 0
println(c)
}
}
prints 0
This is because the code in curly brackets is treated as a closure not as a block.
If I write
class Tester {
static main(args) {
c = 0
if (true) { c = 9 }
println(c)
}
}
then it prints 9
The behaviour of the compiler isn't really a bug but it is surprising behaviour to a C or Java programmer.
I can see no use for the construction and immediate discarding of a closure. Would it be possible for the compiler to treat this construct as a block?