Probably because chomp.gets will work better. The gets.chomp has has chomp getting first crack at info and then chomp passes it along to gets.
That is completely backwards. The OP has it right.
and that helped a great deal. I see now that I was not evaluating the
incrementation.
You guys have been a great help!
Thanks again!
Jeremy B. wrote:
On 10/01/2010 01:29 PM, Mica K. wrote:
if year1 is a leapyear then print year1 + 4
Shouldn’t that prevent 1992 from being printed?
That while condition is only evaluated at the beginning of each pass
through the loop. The first pass (where 1987 <= 1900) adds 1 to year1
making it 1988. The second pass (where 1988 <= 1990) sets leapyear to
year1 + 4 (1988 + 4 = 1992) and then prints leapyear which is now
1992; however, it does not modify the value of year1. From hear on, the
loop continues printing 1992 infinitely because year1 is never updated
again and will always be 1988 which is less than 1990.
That while condition is only evaluated at the beginning of each pass
through the loop. The first pass (where 1987 <= 1900) adds 1 to year1
making it 1988. The second pass (where 1988 <= 1990) sets leapyear to
year1 + 4 (1988 + 4 = 1992) and then prints leapyear which is now
1992; however, it does not modify the value of year1. From hear on, the
loop continues printing 1992 infinitely because year1 is never updated
again and will always be 1988 which is less than 1990.
From: Mica K. [email protected]
To: ruby-talk ML [email protected]
Sent: Fri, October 1, 2010 3:05:20 PM
Subject: New to Ruby, Looking for Help With Basic Program
I am teaching myself Ruby and am trying to figure out why this program
is doing what it is doing: