$0 is the variable for the top level Ruby program, but is there one for the current method?
$0 is the variable for the top level Ruby program, but is there one
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Even better than my first answer you can use
__method__:This returns a symbol – for example,
:test_method. To return the method name as a string, call__method__.to_sinstead.Note: This requires Ruby 1.8.7.