This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| def get_input(prompt = '--> ') | |
| puts '' | |
| puts 'Please enter a number, odd or even.' | |
| print prompt | |
| # if the end-of-input was reached and gets returned a nil | |
| # or the word 'exit' or 'quit' appears (ignoring case) in the input | |
| if (input = gets).nil? || /exit|quit/i =~ input | |
| nil # just return a nil | |
| else |
OlderNewer