On Sun, 28 Jan 2001, Dave Thomas wrote:

> David Alan Black <dblack / candle.superlink.net> writes:
> 
> > I'm just curious -- do you make that distinction automatically (single
> > line use {}, multi line use do/end)?
> 
> Not speaking for Aleksi, but it's a convention that I like. It seems
> to make the blocks fit in better with the other language constructs:
> 
>    for cd in collection
>       cd.each_track do |title|
>          # ...
>       end
>    end
> 
> to me looks cleaner than
> 
>    for cd in collection
>       cd.each_track { |title|
>          # ...
>       }
>    end

I agree -- though I'm not to be trusted, as I also tend to like the
highly unpopular placing of do/end on one line....  In fact, I've gone
over almost exclusively to do/end, especially now that one can chain
them.

> There's another style I;ve seen her which I'm still thinking
> about. Some folks put the block parameters on their own line:
> 
>    a.doit {
>      | name, address |
>      # ...
>    }
> 
> It certainly looks nice, but I can't quite convince myself there's a
> reason to do it ;-)

I originally liked doing that, especially with do/end:

  things.each do
    |t|
    puts t
  end

An argument could be made that breaking the line between the "do"
directive and the start of what it is you're "do"ing makes sense.

I've actually trained myself to put the |t| right by the "do" because
I didn't see many people using the above style.  But it does seem to
be appearing more.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav