From: Rick DeNatale Date: 2007-10-03T00:08:35+09:00 Subject: Re: how to do "do" blocks On 9/28/07, Daniel Talsky wrote: > Well thanks fellas... that makes good sense. > > > You have to use only one form of block, either do...end or {}. The > > convention seems to be to use do...end for multiline blocks, while {} > > is used for one-liners. > > However, there's some lines of thought on the internet that have a > different idea. What do you think of the idea that it's not "one line > vs. multiline" but "returns a value vs. doesn't return a value". > > Here's the two posts I'm talking about: > http://objo.com/2007/6/28/ruby-style-ruby-do-end-versus > http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc > > In the first post, one of the commenters asks: > > As for using {} only when returning a value, doesn't every statement return a > > value (in your example, the array with it's elements capitalised and reversed)? > > And although he's wrong, the code in question: > i.capitalize! > is in-place changing the variable of course... but his point is still > valid. Anyone want to weigh in on this? http://talklikeaduck.denhaven2.com/articles/2007/10/02/ruby-blocks-do-or-brace -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/