Compile error 18 to 0 use next if


#1

hello
in the loop&iterators --> next !
i type the code:
for i in 0..18
next if i %2 == 1
print i
end

the error: it's look like it didn't print out the numbers 18 to 0
why error come out??


#2

Hello. From what I see, what's wrong in your code is that the question he asks to print only the couple, and you put your situation "if" doing the opposite. Try to change that part or follow the instructions below if you have questions about:

i = 20
loop do
i -= 1
next if i % 2 != 0
print "#{i}"
break if i <= 0
end

I hope this helps and good luck.


#3

Thanks a lot!
its work !!!