Newbee Dev Newbee Dev - 27 days ago 5x
Ruby Question

condition to input value always return false (RUBY)

I wonder why even though I type "y" the condition will always false

puts "Would you like to continue [y/n]"
confirm = gets
puts confirm == "y" # why this is not true even I type "y"

if confirm == "y"
puts "Input is y"


Try use confirm = gets.chomp cause gets set what you enter with \n in the end

> a = gets
> y
 => "y\n"