Bug #1017

Curly braces {...} and do ... end

Added by Einar Boson over 6 years ago. Updated almost 4 years ago.

[ruby-core:21373]
Status:Rejected
Priority:Normal
Assignee:-
ruby -v: Backport:

Description

=begin
I gather that curly braces and do..end are supposed to work the same, why then is this ok

def save_block name, &b
  @blocks ||= {}
  @blocks[name] = b
end

save_block :say_hello do
  puts "hello!"
end

but not this:

save_block :say_hello {
  puts "hello!"
}

#ruby 1.9.1p5000 (2009-01-13 trunk 21497) [i386-darwin9.6.0]
=end

History

#1 Updated by Austin Ziegler over 6 years ago

=begin
They aren't actually supposed to work the same. do/end and {/} differ in binding precedence. Your code is the equivalent of:

save_block(:say_hello) do
puts "hello!"
end

save_block(:say_hello {
puts "hello!"
})

That's the difference between the two types of block delimiters. Not new, not a bug.
=end

#2 Updated by Shyouhei Urabe over 6 years ago

  • Status changed from Open to Rejected

=begin

=end

Also available in: Atom PDF