Say I have a function:
def foo() puts getFunctionIAMIn() end I want the output to be:"foo" And if I have this code:
def foo1() puts getFunctionIAMIn() end I want the output to be:"foo1"
Say I have a function:
def foo() puts getFunctionIAMIn() end I want the output to be:"foo" And if I have this code:
def foo1() puts getFunctionIAMIn() end I want the output to be:"foo1"
Just write as below using __method__:
def foo() puts __method__ end Above is correct, but __callee__ sounds more technically correct.
__method__ returns defined name, and __callee__ returns called name.They are same usually, but different in a aliased method.
def foo [__method__, __callee__] end alias bar foo p foo #=> [:foo, :foo] p bar #=> [:foo, :bar] __callee__?__callee__ is more technically correct.. Let me edit.You can use __method__ for that:
def test_method __method__ end