V
Vincent Gabriel Franco
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
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