K
Kaye Ng
I read this in a book.
" In Ruby 1.9, however, local variables used within code blocks will not
interfere with local variables located outside of the block."
I don't know if my code is wrong, but it looks to me like the local
variable inside the code block DOES interfere with the local variable
(with the same name) outside the code block.
x = [1, 2, 3, 4, 5]
var = 1
x.each do
|number| (var = 10)
end
puts var
" In Ruby 1.9, however, local variables used within code blocks will not
interfere with local variables located outside of the block."
I don't know if my code is wrong, but it looks to me like the local
variable inside the code block DOES interfere with the local variable
(with the same name) outside the code block.
x = [1, 2, 3, 4, 5]
var = 1
x.each do
|number| (var = 10)
end
puts var