I just started learning Ruby. I typed the example:
x = 10
5.times do |y; x|
x = y
puts "x inside the block: #{x}"
end
puts "x outside the block: #{x}"
And I have an error:
hello.rb:3: syntax error, unexpected ‘;’, expecting ‘|’
5.times do |y; x|
Explain to me please what does it mean? This code should works, as I understand the chapter.
That’s a new 1.9 construct called block local arguments, you’re using 1.8.
It also works with lambdas (including stabbed), which is nice: