From: Dossy Date: 2002-08-11T08:52:22+09:00 Subject: Re: Style question On 2002.07.31, Jim Freeze wrote: > On Tue, Jul 30, 2002 at 11:19:52PM +0900, Michael Campbell wrote: > > Is there an accepted standard as to when to use {} vs do/end? > > > I personally like the {} for the simple reason that it is easy > to test for matching pairs in vi. > > eg > > [1,2,3].each { |x| > do something... > } > > To me this is easier to debug and looks as elegant as > > [1,2,3].each do |x| > do something... > end Let me ask a related question: is there a accepted standard of where the |...| go? This is what I have been doing: One-liners look like: [1, 2, 3].each { |x| p x } Multi-liners can look like: [1, 2, 3].each { |x| p x p x + 1 } or [1, 2, 3].each { |x| p x p x + 1 } or [1, 2, 3].each do |x| p x p x + 1 end I don't often use "do |x|\n" ... not sure why. I'm trying to decide which of the 3 multi-line versions to commit to using, but it seems there's no One True Way from the sample code I've been reading over ... -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)