From: nobu.nokada@... Date: 2003-06-30T01:43:03+09:00 Subject: Re: Help with UnboundMethod#bind error Hi, At Mon, 30 Jun 2003 00:31:00 +0900, gabriele renzi wrote: > 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: Although I'm not sure what you really want, try instance_method instead. > m=Kernel.method( :met).unbind m=Kernel.instance_method(:met) > now: I know that Mod is a different object. Anyway MEthod#bind should > worry just about obj.class, am I wrong ? Modules and classes always have metaclasses. It might be ok to ignore metaclasses have no influence. Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.470 diff -u -2 -p -r1.470 eval.c --- eval.c 28 Jun 2003 03:29:00 -0000 1.470 +++ eval.c 29 Jun 2003 16:34:32 -0000 @@ -7269,4 +7269,8 @@ mnew(klass, obj, id, mklass) } + while (rklass != klass && + (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) { + rklass = RCLASS(rklass)->super; + } if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass; method = Data_Make_Struct(mklass, struct METHOD, bm_mark, free, data); -- Nobu Nakada