This post originated from an RSS feed registered with Ruby Buzz
by Jim Weirich.
Original Post: Braces Vs Do/End
Feed Title: { | one, step, back | }
Feed URL: http://onestepback.org/index.cgi/synopsis.rss
Feed Description: Jim Weirich's Blog on Software Development, Ruby, and whatever else sparks his interest.
I thought I'd repost the feedback I left at onestepback.
irb(main):006:0> def foo irb(main):007:1> yield irb(main):008:1> end => nil irb(main):009:0> File.open foo { "in.txt" } => # irb(main):010:0> File.open foo do "in.txt" end LocalJumpError: no block given from (irb):7:in `foo' from (irb):10 irb(main):011:0>
In the former, the block is associated with foo, while the second associates it with File.open, which causes problems since foo requires a block.