Mega Code Archive

 
Categories / Ruby / Statement
 

Break out of a block

def oscillator   x = 1   while true     yield x     x *= -2   end end oscillator { |x| puts x; break if x.abs > 50; }