Yukihiro Matsumoto wrote:
> Hi,
> 
> In message "Re: rescue *[]"
>     on 04/01/30, Joel VanderWerf <vjoel / PATH.Berkeley.EDU> writes:
> 
> |How do you get the behavior your describe ("nothing should be rescued"), 
> |_except_ by using the *[] trick?
> 
> The *[] trick is the only way (I think) for "nothing should be
> rescued".  But I guess it's OK, since virtually no one want to handle
> zero exception in rescue clause.
> 
> |I still don't see why *[] should behave differently for rescue than for 
> |methods.
> 
>   * method without argument is common.
>   * rescue without capturing exception is *very* uncommon.
>   * but it is still reasonable to leave *[] as nothing for
>     consistency's sake.
> 
> 							matz.

Ok, thanks for the explanations. I can easily get the behavior I want:

class FooErr < StandardError; end
class BarErr < StandardError; end

def handle_exceptions(*args)
   args = [StandardError] if args.empty?
   yield
rescue *args
   puts "handled"
end

handle_exceptions(FooErr, BarErr) do
   raise BarErr
end

handle_exceptions do
   raise
end

# output:
#    handled
#    handled