From: "Jesús Gabriel y Galán" Date: 2007-09-28T17:59:26+09:00 Subject: Re: how to do "do" blocks On 9/28/07, Daniel Talsky wrote: > > 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? I'm fairly new to Ruby, and still trying to accomodate my style (coming from java it's taking me a while to use do...end, my fingers type the { automatically :-), but I'm pretty sure I've read many times here what I said above, and those articles also imply that's the more widely accepted answer to that question. I can't comment on other people's uses of this. Maybe more knowledgeable people here could chime in? Jesus.