3 ms·
irb(main):001:0> x = 0; xs = [1,2,3]; xs.each { |x| puts x }; puts x 1 2 3 3
by kscaldef 16y ago
irb(main):001:0> x = 0; xs = [1,2,3]; xs.each { |x| puts x }; puts x
1
2
3
3
- grammaton 16y agoYes, x is a lexically scoped variable, and you're using a code block, which is not in any way like a function. And?
- msbarnett 16y agoOh right, that bit of unpleasantness. Mercifully, that's been fixed since 1.9: ruby-1.9.2-p0 > x = 0; xs = [1,2,3]; xs.each { |x| puts x }; puts x 1 2 3 0 => nil