From: "Brian Schröder" Date: 2005-05-12T16:48:10+09:00 Subject: Re: object loops and what they return On 12/05/05, Phrogz wrote: > Eric Mahurin wrote: > > That sure looks ugly. I don't see any advantage of this over: > > > > my_array.each do |item| > > puts "item" > > end > > if my_array.empty? > > puts "(no items found)" > > end > > *shrug* I personally prefer what I posted over this. (I tend to use { > and } for blocks instead of begin/end in my own code because IMHO it > visually groups it better, but I used begin/end here since that seems > to be the emerging multi-line choice of the community.) > [snip] I just wanted to throw in that I'm in the camp of people who use begin end when the side effect is important and braces when the return value is important. This conveys more meaning on a causual glance. I.e. print "100!" puts (1..100).inject(1) { | r, i | r*i } (1..100).inject(1) do | r, i | puts "#{i}! = #{r = r*i}" end regards, Brian Schr�der -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/