The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Braces Vs Do/End

1 reply on 1 page. Most recent reply: Jul 31, 2004 10:15 PM by Chris Dutton

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jim Weirich

Posts: 351
Nickname: jimw
Registered: Jul, 2003

Jim Weirich is a long time software developer and a relatively recent Ruby enthusiast.
Braces Vs Do/End Posted: Jul 29, 2004 6:39 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jim Weirich
Latest Posts From { | one, step, back | }

Advertisement
When should you use { } vs do/end?...

Read: Braces Vs Do/End


Chris Dutton

Posts: 15
Nickname: cdutton
Registered: Jul, 2004

Re: Braces Vs Do/End Posted: Jul 31, 2004 10:15 PM
Reply to this message Reply
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.

Flat View: This topic has 1 reply on 1 page
Topic: 50+ Gems Available Previous Topic   Next Topic Topic: Not Dumb Enough

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use