Hi,
I was just wondering, why doesn’t Kernel.method() call method_missing() when
it can’t find a method, instead of raising a NameError?
Chris
Hi,
I was just wondering, why doesn’t Kernel.method() call method_missing() when
it can’t find a method, instead of raising a NameError?
Chris
I was just wondering, why doesn't Kernel.method() call method_missing() when
it can't find a method, instead of raising a NameError?
Well, probably you make a confusion
Kernel#method create a Method object, for example
pigeon% ruby -e 'def tt() end; p method(:tt)'
#<Method: Object(Object)#tt>
pigeon%
Now ruby effectively call #method_missing when it don't find a
method
pigeon% ruby -e 'qq()'
-e:1: undefined method `qq' for #<Object:0x401bace0> (NameError)
pigeon%
pigeon% ruby -e 'def method_missing(id) p "missing #{id}"; end; qq()'
"missing qq"
pigeon%
Guy Decoux
D’oh!
Of course, because Kernel.method() is only returning a Method object, but
not actually calling that method.
I think my confusion was because the only places I have ever used method(),
I have in fact used it like this:
method(methodName).call(*args)
…so I guess I had stopped thinking about the Method object as an object
at all.
Cool.
----- Original Message -----
From: “ts” decoux@moulon.inra.fr
Newsgroups: comp.lang.ruby
Sent: Tuesday, November 19, 2002 9:36 AM
Subject: Re: Kernel.method() question
I was just wondering, why doesn’t Kernel.method() call method_missing()
when
it can’t find a method, instead of raising a NameError?
Well, probably you make a confusion