From: Jean Helou Date: 2006-10-02T22:41:18+09:00 Subject: Re: Creating dynamically named singleton methods. Syntax question. However this will define the given method for all new instances of obj.class (MyThing in my example) which are created after this code is executed, which is not what the OP seemed to want. jean ps: in my example :test can be a variable and String.to_sym is your friend. On 10/2/06, Martin Coxall wrote: > On 10/2/06, Jan Svitok wrote: > > > > On 10/2/06, Luke Stark wrote: > > > You may create singleton methods like so: > > > > > > I'll have one more go. This time I'll get it right. ;p > > obj.class.instance_eval do > define_method(:method_name) do |*args| > # Method goes here > end > end > > N.B. this actually works this time, because I tried it. > > Regards, > > Martin > >