Skip to content

Instantly share code, notes, and snippets.

@marcric
Created December 26, 2008 19:49
Show Gist options
  • Save marcric/40115 to your computer and use it in GitHub Desktop.
Save marcric/40115 to your computer and use it in GitHub Desktop.
def read_from_user_input
puts "Please insert a year to see if it's a Leap year: "
STDOUT.flush
gets.chomp
end
def validator(a_string)
if(x=(a_string.scan(/\D/).size==0))
puts "numeric"
puts a_string
exit
else
puts"non-numeric"
end
end
def iterator
validated=case
when validator(read_from_user_input).nil? then read_from_user_input
else
puts"after while"
return validator(read_from_user_input).to_i
end
end
iterator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment