Link Details

Link 45573 thumbnail
User 217101 avatar

By gst
via talklikeaduck.denhaven2.com
Published: Oct 03 2007 / 09:13

Conventional wisdom in Ruby is to use do/end to delimit blocks which contain more than one line of code, and braces for one-line blocks. I've always tended to loosely follow this advice. Thanks to ruby-talk, I just became aware of Jim Weirich's suggestion to use braces for blocks when the value is being used, and do/end for blocks which are primarily sequences of statements. Jim actually posted this over three years ago, and Joe O'Brien brought it up more recently. On the whole, I like this idea and will probably adopt it to tune my use of do/end vs. braces.
  • 15
  • 0
  • 1145
  • 430

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (15)



Voters Against This Link (0)