3 ms·
Sure, Ruby: x = (1..100).each do |i| if i > 9 break i end end Evaluating that gives > x => 10 You can also supply a
by msbarnett 9y ago
Sure, Ruby:
x = (1..100).each do |i|
if i > 9
break i
end
end
Evaluating that gives
> x
=> 10
You can also supply a value to next within a loop, which is occasionally useful