This is because you call the choices method before defining it. Write the code as shown below:
puts "Select [1] [2] [3] or [q] to quit" users_choice = gets.chomp def choices (choice) while choice != 'q' case choice when '1' break puts "you chose one!" when '2' break puts "you chose two!" when '3' break puts "you chose three!" end end end choices(users_choice)
I used break to exit the while . Otherwise, it will create an infinite loop.
source share