Created
March 7, 2011 12:53
-
-
Save technicalpickles/858471 to your computer and use it in GitHub Desktop.
fun with super
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 > class Foo; def bar; super; end; end | |
nil | |
ree-1.8.7-2010.02 :002 > Foo.new.bar | |
NoMethodError: super: no superclass method `bar' for #<Foo:0x101bc7120> | |
from (irb):1:in `bar' | |
from (irb):2 | |
ree-1.8.7-2010.02 :003 > class Foo; def bar; super if defined?(super); end; end | |
nil | |
ree-1.8.7-2010.02 :004 > Foo.new.bar | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment