From: Robert Klemme Date: 2003-03-17T21:42:01+09:00 Subject: Re: dynamically create a method "Rudolf Polzer" schrieb im Newsbeitrag news:slrnb7b7ev.as5.abuse@durchnull.de... > Scripsit ille �Robert Klemme� : > > isn't this easier? > > > > class Fixnum > > def power(exp) > > self ** exp > > end > > end > > > > a=10 > > a.power 2 > > It is, but there might be cases where one does not know the name of the > method in advance. This wasn't obvious from the original poster's example. But I agree, for those cases one of the eval approaches has to be used. > Perhaps when dynamically creating more than one method > in method_missing(). Hm, I could not imagine a scenario where method_missing is used to actually create methods. Typically I'd create them before they are missed. Can you provide an example? > And... wasn't there a way to convert a string to a symbol? Yes: irb(main):006:0> "foo".intern.type Symbol irb(main):007:0> Ciao robert