Skip to content

Instantly share code, notes, and snippets.

View rab's full-sized avatar
👨‍💻
Home Office is a mess (as usual)

Rob Biedenharn rab

👨‍💻
Home Office is a mess (as usual)
View GitHub Profile
# 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