Force User to Answer - gets.chomp


How can we force the user to enter a response?

For example. If the user doesn't type anything, the question would keep looping until the user enters text.


Assuming you're storing the string in a variable, you could use a while loop with the code inside of it to check if the variable is empty with .empty, like this:

   // code


As a new Ruby learner I’m still not able to wrap my head around this. Would you be able to show us using the example from the lesson?

Thanks in advance!