Skip to content

Instantly share code, notes, and snippets.

@taisyo7333
Created January 25, 2016 14:02
Show Gist options
  • Save taisyo7333/aa69fd8018a6191208a8 to your computer and use it in GitHub Desktop.
Save taisyo7333/aa69fd8018a6191208a8 to your computer and use it in GitHub Desktop.
Ruby Class : override instance method.
# encoding: SJIS
class Hoge
def method_missing(m,*args)
p "called:" + m.to_s
super # call original exception
end
end
Hoge.new.no_method
>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