G
gabriele renzi
Hi gurus and nubys,
I'm having a little problem with unbound methods.
I supposed I could unbound a method from Kernel
and put it in my own module, but it seems' I'm failing:
# this should go in Kernel
def met
p 'met'+self.to_s
end
m=Kernel.method( :met).unbind
module Mod;end
m.bind(Mod) #failing!
#but M.kind_of?(Kernel.class) #=>true
the error is :
Ruby1:13:in `bind': singleton method called for a different
object(TypeError)
now: I know that Mod is a different object. Anyway MEthod#bind should
worry just about obj.class, am I wrong ?
Or the problem is that :met is a singleton method ?
If so, why I can't detach a singleton method ?
I'm having a little problem with unbound methods.
I supposed I could unbound a method from Kernel
and put it in my own module, but it seems' I'm failing:
# this should go in Kernel
def met
p 'met'+self.to_s
end
m=Kernel.method( :met).unbind
module Mod;end
m.bind(Mod) #failing!
#but M.kind_of?(Kernel.class) #=>true
the error is :
Ruby1:13:in `bind': singleton method called for a different
object(TypeError)
now: I know that Mod is a different object. Anyway MEthod#bind should
worry just about obj.class, am I wrong ?
Or the problem is that :met is a singleton method ?
If so, why I can't detach a singleton method ?