Tom Agnew wrote:
> Greetings,
> 
> I just discovered undocumented but very useful syntax:
> 
>     break <expression>
> 
> The expression seems to add a useful feature to a 'while', 'until' or
> 'for' control structure.  For example:
> 
>     result = while <condition>
>     ...
>       break <something>
>     ...
>     end
> 
> 'result' is nil if the loop exits with <condition> and is <something> 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