Hello --

On Sat, 6 Jan 2001, Kenichi Komiya wrote:

> For example, Ruby allow you to write something like bellow.
> 
>   # case-insensitive sort
>   ["Foo", "bAr", "zoT"].collect{ |str| 
>     [str.downcase, str]
>   }.sort.collect{ |pair| 
>     pair[1]
>   }
>   # => ["bAr", "Foo", "zoT"]
> 
> But you can not simply replace { .. } with do .. end here (coz, the
> call of sort is not allowed after do .. end).

Have you tried it?  :-)


     ["Foo", "bAr", "zoT"].collect do |str|
        [str.downcase, str] end .sort.collect do |pair|
          pair[1]
        end

# => ["bAr", "Foo", "zoT"]


I know I've hit snags with doing this, though right now I can't seem
to recreate them.  But there does not seem to be any general rule against
chaining do/end blocks.


David

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