Ruby Keyword: break - rking/pry-docmore GitHub Wiki
Hops out of the inner-most loop. Like this:
%w(a b c).each do |i|
print i
32343.times do |j|
break if j > 2
print j
end
end
puts
Prints:
a012b012c012
Also note that the keyword accepts an argument:
x = loop do break 3 end
p x
# ⇒ 3
Compare with: next, last