From: An Nguyen Date: 2011-04-05T12:38:01+09:00 Subject: Block variables Dear all, I'm new comer in Ruby Forum and Ruby. When I read a page about the *block variables* [followed link] http://rubylearning.com/satishtalim/ruby_blocks.html With the snipet x = 10 5.times do |x| puts "x inside the block: #{x}" end puts "x outside the block: #{x}" and the output is: # x inside the block: 0 # x inside the block: 1 # x inside the block: 2 # x inside the block: 3 # x inside the block: 4 # x outside the block: 10 And they say "You will observe that after the block has executed, x outside the block is the original x. Hence the block parameter x was local to the block." I tested with my Ruby 1.8.7 and the output must be: # x inside the block: 0 # x inside the block: 1 # x inside the block: 2 # x inside the block: 3 # x inside the block: 4 # x outside the block: 4 So the question is here: Why are they different here ? Problem is from version or this page has mistake ? -- Posted via http://www.ruby-forum.com/.