Displaying 1 result from an estimated 1 matches for "__method__".
Did you mean:
__method
2013 Sep 06
1
How to get local variable name from object id or memory reference in ruby?
Follow the code :-
class Sample
def bar
p method(__method__).receiver # only `self` would do the trick.
end
end
n1=Sample.new # => #<Sample:0x13bc648>
n2=Sample.new # => #<Sample:0x13bc630>
n1.bar # => #<Sample:0x13bc648>
n2.bar # => #<Sample:0x13bc630>
But this is my try. I am looking for any method is availabl...