coderrr | 17 May 02:04

Re: Matz: can we have rescue/else/ensure available in all blocks?

> I'm certainly not convinced.  Maybe you could post a more real world
> example because I'm having a hard time seeing the usefulness in nested
> rescues.
>
>
This has nothing to do with nested rescues.  I merely used that in the
example to make it more compelling, although I guess for you it did the
opposite :P

Here's how you can get some real world examples:
cat > findem.rb <<EOF
ARGV.each do |fn|
  data = File.read(fn)
  ms = data.scan(%r{
            do \s* (?:\| [^|]* \|)+ \s*
                begin
                  (?:(?!end).)+?
                end \s*
            end
             }mx)

  if ! ms.empty?
    puts fn
    ms.each{|m| puts m }
  end
end
EOF

find /usr/lib/ruby/gems/1.8/gems -name "*.rb" | xargs ruby findem.rb >
the_real_world

for me:
grep \\.rb the_real_world | wc -l
=> 43

- steve
http://coderrr.wordpress.com

Gmane