Created
December 29, 2011 00:42
-
-
Save donnoman/1530756 to your computer and use it in GitHub Desktop.
Ruby Raise in a block test
This file contains hidden or 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
ree-1.8.7-2010.02 :001 > def me | |
ree-1.8.7-2010.02 :002?> yield | |
ree-1.8.7-2010.02 :003?> end | |
=> nil | |
ree-1.8.7-2010.02 :004 > | |
ree-1.8.7-2010.02 :005 > me do | |
ree-1.8.7-2010.02 :006 > begin | |
ree-1.8.7-2010.02 :007 > raise "goobers" | |
ree-1.8.7-2010.02 :008?> rescue | |
ree-1.8.7-2010.02 :009?> p "I caught the goober" | |
ree-1.8.7-2010.02 :010?> end | |
ree-1.8.7-2010.02 :011?> end | |
"I caught the goober" | |
=> nil | |
ree-1.8.7-2010.02 :012 > | |
ree-1.8.7-2010.02 :013 > | |
ree-1.8.7-2010.02 :014 > me do | |
ree-1.8.7-2010.02 :015 > raise "gobblers" rescue p "I cought the gobbler" | |
ree-1.8.7-2010.02 :016?> end | |
"I cought the gobbler" | |
=> nil | |
ree-1.8.7-2010.02 :017 > | |
ruby-1.9.2-p180 :001 > def me | |
ruby-1.9.2-p180 :002?> yield | |
ruby-1.9.2-p180 :003?> end | |
=> nil | |
ruby-1.9.2-p180 :004 > | |
ruby-1.9.2-p180 :005 > me do | |
ruby-1.9.2-p180 :006 > begin | |
ruby-1.9.2-p180 :007 > raise "goobers" | |
ruby-1.9.2-p180 :008?> rescue | |
ruby-1.9.2-p180 :009?> p "I caught the goober" | |
ruby-1.9.2-p180 :010?> end | |
ruby-1.9.2-p180 :011?> end | |
"I caught the goober" | |
=> "I caught the goober" | |
ruby-1.9.2-p180 :012 > | |
ruby-1.9.2-p180 :013 > | |
ruby-1.9.2-p180 :014 > me do | |
ruby-1.9.2-p180 :015 > raise "gobblers" rescue p "I cought the gobbler" | |
ruby-1.9.2-p180 :016?> end | |
"I cought the gobbler" | |
=> "I cought the gobbler" | |
ruby-1.9.2-p180 :017 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yup. that explains it.
see, did learn something today :)
Cheers man!