From: "Mark J. Reed" Date: 2004-01-02T14:06:45+09:00 Subject: Re: Loop/Iterator questions On Thu, Jan 01, 2004 at 08:55:54PM -0800, GGarramuno wrote: > 1) Is there anything like Perl's continue block available? Not that I'm aware of, although I could easily be mistaken. But Ruby's looping primitives are in general rather, well, primitive, since most of the time an iterator method is used instead. > 2) Is there anything like labels for iterators or loops? This allows > you to do next, last, etc. on outside loops, like: > > loop1: while x > 1 > while y > 1 > if t2 then next loop1 > end > end > > This could be emulated with a flag and an ugly if check, but I hope > not. That sort of nonlocal control flow is done with catch/throw in Ruby. catch(:done) do while x > 1 while y > 1 if t2 then throw :done end end end Catch and throw are explicitly designed for this sort of thing, unlike raise/rescue which are for genuine error conditions. -Mark