Created
January 25, 2016 14:02
-
-
Save taisyo7333/aa69fd8018a6191208a8 to your computer and use it in GitHub Desktop.
Ruby Class : override instance method.
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
# encoding: SJIS | |
class Hoge | |
def method_missing(m,*args) | |
p "called:" + m.to_s | |
super # call original exception | |
end | |
end | |
Hoge.new.no_method |
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
>ruby Code4-11.rb | |
ruby Code4-11.rb | |
"called:no_method" | |
Code4-11.rb:6:in `method_missing': undefined method `no_method' for #<Hoge:0x2267478> (NoMethodError) | |
from Code4-11.rb:10:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment