I am going through the Ruby tutorials from Learn to Program, and I am having a problem with a while loop.
This is what I want to do:
while y_now % 4
y_now += 1
puts y_now % 4
end
gets
I'm using the gets
just to pause execution so I can see the output. (This is looking for a leap year, btw)
Anyways, when y_now % 4 = 0
, the while loop continues, and I don't understand why, since this is different from all my previous experience.
I don't want someone to just fix my code though, I really want to understand why this happens. I've obviously just started Ruby, so whatever help I get is very much appreciated.
Note: This seems to be similar to this question, but with integers instead of strings.