How to get the name of the executing method?

G

Gary Wright

How do I use reflection to get the name of the executing method?

There were two methods, __method__ and __callee__ in 1.9 for
that provided this information. __method__ returned the
name used when the method was defined and __callee__ provided
the name used to call the method (i.e., via an alias).

They got lost in the merge of YARV into the 1.9 code base.
I just posted a request to ruby-core to have them added back
in.

If you've got two methods that only differ in how they
interpret their arguments it might be nice to simply use
the name of the alias to select the correct argument
processing rather then having two methods that eventually
make a call to a more generalized third method to do the
work.

Gary Wright
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top