I am trying to understand how CoffeeScript variables are scoped. According to the documentation:
This behavior is effectively identical to Ruby's scope for local variables.
However, I found out that it works differently.
In CoffeeScript
a = 1
changeValue = -> a = 3
changeValue()
console.log "a: #{a}" #This displays 3
In Ruby
a = 1
def f
a = 3
end
puts a #This displays 1
Can somebody explain it, please?