From: Joel VanderWerf Date: 2005-10-31T08:10:51+09:00 Subject: Re: Very useful... 'break' accepts an argument Tom Agnew wrote: > Greetings, > > I just discovered undocumented but very useful syntax: > > break > > The expression seems to add a useful feature to a 'while', 'until' or > 'for' control structure. For example: > > result = while > ... > break > ... > end > > 'result' is nil if the loop exits with and is if > the break is executed. > > Very useful and provides an cool addition to an already elegant > collection of iterator constructs! > > Tom Agnew3 > It's also cool because it works with your own iterators (really, any method that takes a block), not just ruby syntax like while. def foo yield end x = foo do break 4 end p x -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407