Created
January 13, 2016 09:47
-
-
Save tonekk/308d1dc02af0e22209a4 to your computer and use it in GitHub Desktop.
This file contains 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
lifes = 9 | |
puts "Try to kill me, I got #{lifes} lifes!\n" | |
loop do | |
begin | |
sleep 1 | |
rescue Exception => e | |
lifes = lifes - 1 | |
if lifes == 0 | |
puts "Bye bye, I'm dead" | |
exit | |
else | |
puts "You hit me, still got #{lifes} life#{lifes > 1 ? 's' : ''} :)\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why you should never catch
Exception
in rubyExecute this program and try to kill it with
ctrl-c
. You'll be surprised how sustainable a cat is.