From: Rick DeNatale Date: 2010-01-18T08:59:11+09:00 Subject: Re: name of method? On Sun, Jan 17, 2010 at 5:29 PM, Ralph Shnelvar wrote: > How do I get the name of a method? > > def xxx >  @WhatsMyName = ??? > end > > > What should ??? be?  I want it to return "xxx". Here's a bit of a hack using caller. def method_name caller.first.match(/in `(.*)'/)[1] end class Foo def bar puts method_name end alias_method :baz, :bar end Foo.new.bar Foo.new.baz outputs: bar baz -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale