Skip to content

Instantly share code, notes, and snippets.

@chyld
Created November 12, 2012 15:37
Show Gist options
  • Save chyld/4060029 to your computer and use it in GitHub Desktop.
Save chyld/4060029 to your computer and use it in GitHub Desktop.
puts "GIMMIE A NUMBER!"
response = gets.to_i
# asks the user for a number and stores the input into variable response
begin
response.explode
# explodes the program and causes an error
rescue
puts "The square of #{response} is #{response**2}."
# initiates the rescue code if the program fails
end
# ,---, ,---, ,---,
# ,`--.' | ,`--.' | ,`--.' |
# .---. ,---, ,---,| : : | : : | : :
# /. ./| .' .' `\ ,`--.' |' ' ; ' ' ; ' ' ;
# .--'. ' ;,---.' \ | : :| | | | | | | | |
# /__./ \ : || | .`\ |: | '' : ; ' : ; ' : ;
# .--'. ' \' .: : | ' || : || | ' | | ' | | '
# /___/ \ | ' '| ' ' ; :' ' ;' : | ' : | ' : |
# ; \ \; :' | ; . || | |; | ; ; | ; ; | ;
# \ ; ` || | : | '' : ;`---'. | `---'. | `---'. |
# . \ .\ ;' : | / ; | | ' `--..`; `--..`; `--..`;
# \ \ ' \ || | '` ,/ ' : |.--,_ .--,_ .--,_
# : ' |--" ; : .' ; |.' | |`. | |`. | |`.
# \ \ ; | ,.' '---' `-- -`, ;`-- -`, ;`-- -`, ;
# '---" '---' '---`" '---`" '---`"
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment