Just started learning looping and flow control in Ruby and got stuck with this exercise. I've been testing and searching for answers but did not find any so I'm posting here.
If I have my code setup like this:
ask_play = ''
loop do
print "Play?: "
ask_play = gets.chomp
break if (ask_play == 'n') || (ask_play == 'N')
end
Then I exit out of the loop after entering n or N.
However, if I have my code setup like this:
ask_play = ''
play_stop = (ask_play == 'n') || (ask_play == 'N')
loop do
print "Play?: "
ask_play = gets.chomp
break if play_stop
end
The condition does not seem to work. I still keep on looping even after typing in n or N and I'm just puzzled why.