Hi,

In message "The names of a method"
    on 02/11/27, Klaus Fabritius <kfk / wasserhase.de> writes:

|I want do do something like that:
|
|def foo
|  puts the_name_the_method_was_called_with
|end ; alias bar foo
|
|foo  =>  "foo"
|bar  =>  "bar"
|
|Is there a thing like the_name_the_method_was_called_with?

caller(0) may help.

% ri caller
--------------------------------------------------------- Kernel::caller
     caller( [anInteger] ) -> anArray
------------------------------------------------------------------------
     Returns the current execution stack---an array containing strings
     in the form ``file:line'' or ``file:line: in `method'''. The
     optional anInteger parameter determines the number of initial stack
     entries to omit from the result.
        def a(skip)
          caller(skip)
        end
        def b(skip)
          a(skip)
        end
        def c(skip)
          b(skip)
        end
        c(0)   #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10"]
        c(1)   #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11"]
        c(2)   #=> ["prog:8:in `c'", "prog:12"]
        c(3)   #=> ["prog:13"]

							matz.