3 ms·
In coffeescript 1.3.1 this code: a = 3 b = -> for a in [6,7,8] c = a b() console.log(a) would print "3". In coffeescript 1.3.3 i
by __david__ 14y ago
In coffeescript 1.3.1 this code:
a = 3
b = ->
for a in [6,7,8]
c = a
b()
console.log(a)
would print "3". In coffeescript 1.3.3 it prints "8".
The solution is either to rename one of the 'a' variables or add
`var a`
in the b() function.
Coming from C where I always (ok 99% of the time) do:
for (int i=0; ...)
the loop scoping rules in the 1.3.1 version of coffeescript felt natural. The 1.3.3 change feels stupid.