From: Jason Mayer Date: 2007-02-07T13:27:11+09:00 Subject: Re: newbie question ------=_Part_24117_4639356.1170822429398 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I had to work to make your code run. Here's the deal. The while loop is initialized and then it asks for their input. If their input is nothing, then it goes through the rest of the code in the while loop, finishes the while loop and then the value quit is checked again. at that point the value quit == true, and so the loop ends. Does that make sense? Also, if someone puts in a blank carriage return on the first one and then a number on the second, the value continues to be false. On 2/6/07, Vincent Gabriel Franco wrote: > > I am very new to programming "infant new" > and I have a question about a return I am scratching my head over in a > simple program I am writing > > here is my code... shouldn't the return of my method be "true" after > pressing enter and thus end the loop? > > while (quit == false) > def check_if_blank input > if(input == '') > quit = true > else > quit = false > end > quit > end > puts 'Enter a number' > first = gets.chomp > quit = check_if_blank first > first_number.push first.to_i > > puts 'good..' > puts 'now enter a number to multiply the first number by' > > second = gets.chomp > quit = check_if_blank(second) > second_number.push(second.to_i) > answer.push first_number[(first_number.length) -1] * > second_number[(second_number.length) -1] > > puts first_number[(first_number.length) -1].to_s + ' * ' + > second_number[(second_number.length) -1].to_s + ' = ' + > answer[(answer.length) -1].to_s > if(first_number.length == 5) > quit = true > end > end > > > ------=_Part_24117_4639356.1170822429398--