From: David Alan Black Date: 2001-01-12T06:24:16+09:00 Subject: [ruby-talk:9156] Re: what about this begin? On Fri, 12 Jan 2001, Avi Bryant wrote: > > On Fri, 12 Jan 2001, [iso-8859-1] Anders Strandl�v Elkj�r wrote: > > > > > > > Hiyas. I am a bit puzzled about the use of 'do', 'begin' and 'end'. Why do > > you sometimes need the begin and other times not. > > 'begin' is not needed with 'do', 'while', 'if', etc. It is only used when > paired with rescue/ensure to catch exceptions. 'begin' is analagous to > 'try' in some other languages. Also begin/end blocks can be used with certain modifiers: begin [stuff...] end until x > 10 There was a bunch of discussion a while ago on the interaction of these blocks and the rescue blocks -- for instance, this: begin [stuff...] rescue [other stuff...] end until x > 10 will test x before running the block once. I'm not sure what Matz's current is of whether to retain this behavior or not. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav