__callee__
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (38)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
__callee__()
public
Returns the called name of the current method as a Symbol. If called outside of a method, it returns nil.
__callee__ and __method__ both return symbol when originally defined, not current
There has been some indication that __callee__ is intended to return the symbol with which the method was actually invoked, whereas __method__ returns name with which the method was originally defined, but __callee__ actually behaves identically to __method__ in Ruby 1.9.1 1.9.2, and 1.9.3.
This distinction is meaningful, because methods can be aliased after they are created.
In Ruby 1.8.7, it was possible (though) not convenient to get the name of the method as actually invoked, by calling another method that extracts the name from caller.first. Even that hack no longer works in Ruby 1.9 though, since it will return the originally defined method name as well.