From: w_a_x_man Date: 2010-10-02T22:50:15+09:00 Subject: Re: New to Ruby, Looking for Help With Basic Program On Oct 1, 1:05 pm, Mica Koizumi wrote: > I am teaching myself Ruby and am trying to figure out why this program > is doing what it is doing: > > puts 'Year 1?' > year1 = gets.chomp > puts 'Year 2?' > year2 = gets.chomp > > while (year1.to_i <= year2.to_i) > if year1.to_i % 4 == 0 >   leapyear = year1.to_i + 4 >   puts leapyear > end > if year1.to_i % 4 != 0 >   year1 = year1.to_i + 1 >   puts year1 > end > end > > When year1 = 1987 and year2 = 1990, why is it printing out 1992? I am > expecting 1988. > > Thanks in advance... > -- > Posted viahttp://www.ruby-forum.com/. puts (1987..1999).select{|n| 0 == n%4 } 1988 1992 1996