From: Brian Candler Date: 2007-04-05T06:18:43+09:00 Subject: Re: A Syntax question.. On Thu, Apr 05, 2007 at 03:01:56AM +0900, Sonny Chee wrote: > Hey Guys, > > I would have thought the following two code snippets were equivalent. > However, only the first one will raise err. Can someone explain to me > how I should be 'reading' the 2nd snippet? > > > rescue Exception => err > begin > RDoc::usage > rescue SystemExit > end > raise err > > > rescue Exception => err > begin RDoc::usage rescue SystemExit end > raise err These are two different syntactic constructions. rescue returns the value of , unless there is an exception in which case it returns the value of In this construct, you cannot specify the exception class. I think it only catches StandardError and subclasses. Typical usage: foo rescue nil # just ignore StandardError a = foo rescue bar rescue baz # return value from foo, if exception # then bar, if exception then baz Regards, Brian.