Skip to content

Instantly share code, notes, and snippets.

@campbecf
Forked from anonymous/ask_for_number.rb
Last active July 24, 2017 15:37
Show Gist options
  • Save campbecf/61132efbac5806b9d40c29bda4d1d4ec to your computer and use it in GitHub Desktop.
Save campbecf/61132efbac5806b9d40c29bda4d1d4ec to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
prompt = '--> '
def test_user_input(number)
return "\n '#{number}' is an EVEN number. \n" if number.even?
" '#{number}' is an odd number. "
end
puts ''
puts 'Please enter a number, odd or even.'
puts ''
print prompt
number = gets.chomp.to_i
puts test_user_input(number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment