puts "Tem dinheiro? s/n"
x = gets.chomp
if x = s
puts "Vou viajar"
else
puts "Não vai ser dessa vez"
end
puts "Tem dinheiro? s/n"
x = gets.chomp
if x = s
puts "Vou viajar"
else
puts "Não vai ser dessa vez"
end
First, you have to organize the code, not just play everything anyway.
Second, to compare a variable with a text is only possible if this text is expressed in its literal form, that is, it must be enclosed in quotation marks. Like a quote in a text.
Third, in%% is assigning a value to the variable with if
, to compare and get a true or false the correct operator is =
.
So:
puts "Tem dinheiro? s/n"
x = gets.chomp
if x == "s"
puts "Vou viajar"
else
puts "Não vai ser dessa vez"
end
See running on ideone .
I suggest taking a course on programming before attempting to write code at random.