Ruby Break statement
Ruby Break statement
The Ruby Break statement is used to leave a block when a condition is fulfilled.
Break Statement syntax
break
Break Statement example
for x in 1..7
if x > 4 then
break
end
puts "The value of x = #{x}"
end
Output
The value of x = 1
The value of x = 2
The value of x = 3
The value of x = 4