On 17/08/05, len <lsumnler / gmail.com> wrote:
> Thanks everyone
> 
> I thought this was the case but I wanted to make sure I didn't miss
> something.  I will check out the poignant guide.
> 
> Len Sumnler
> 

There are two schools regarding the use of {} vs do - end. Some use it
for one-liners against multiple liners, others use to distinguish
blocks where the return value is used vs. blocks where the side effect
is used.
I personally prefer the second option, because it makes code a bit
more salient and easier to read and you don't have to change the
delimiters when reformating code.

E.g.

Use the side-effect:
10.times do puts "Side-Effekt" end

result = []
%w(a b c d).each do | a |
  %w(A B C D).each do | b |
    result << [a, b]
  end
end

Use the return value:
puts Array.new(10) { "Side-Effekt" }

result =
  %w(a b c d).inject([]) { | r, a | 
    %w(A B C D).inject(r) { | r, b |
      r << [a, b]
    }
  }

regards,

Brian

-- 
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/