Use
Kernel#loop
with break
rather than begin/end/until
(or while
). 5
6begin
7 do_something
8end while some_condition 9
10b = [1, 2, 3, 4, 5]
11puts b
Description
while
/until
should be used at the beginning of the block, and without the begin
statement.
Bad practice
begin
puts i
i += 1
end while i < 10
Recommended
while i < 10
puts i
i += 1
end