How to use for loop with next to skip the rest of the current iteration in Ruby

1 Answer

0 votes
for x  in  1..10
    if  x < 5 then
        next
    end
    puts "x=#{x}"
    x += 1
end
 
 
 
# run:
#
# x=5
# x=6
# x=7
# x=8
# x=9
# x=10
#

 



answered Dec 22, 2020 by avibootz

Related questions

2 answers 237 views
1 answer 191 views
191 views asked Dec 22, 2020 by avibootz
1 answer 201 views
2 answers 183 views
183 views asked Dec 22, 2020 by avibootz
...