On 5/11/07, Rick DeNatale <rick.denatale / gmail.com> wrote: > On 5/10/07, MenTaLguY <mental / rydia.net> wrote: > > On Fri, 11 May 2007 07:06:29 +0900, Vasco Andrade e silva <vascoas / gmail.com> wrote: > > > > > By the way are class_eval, module_eval, instance_eval and instance_exec > > > the only exceptions? > > > > In Ruby's core library, yes. It's possible to implement new methods with similar behavior (which is occasionally useful), but that isn't the norm. > > Don't forget define_method . You are a genius Rick!!! So eventually I found what OP needs ;) class A def a &blk i = 1 m = methods i += 1 while methods.include? "x#{i}" self.class.send :define_method, "x#{i}", &blk send "x#{i}", 42 self.class.send :remove_method, "x#{i}" end end a = A.new a.a {|p| puts "#{self}: #{p}"} puts a.methods Probably worth looking into Mauricios Eigenklass. He probably did it much better maybe caching the method (no idea how to avoid potential conflicts) ... Cheers Robert > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > > -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw