Method: Kernel#__method__

Defined in:
eval.c

#__method__Object

Returns the name at the definition of the current method as a Symbol. If called outside of a method, it returns nil.



1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
# File 'eval.c', line 1935

static VALUE
rb_f_method_name(VALUE _)
{
    ID fname = prev_frame_func(); /* need *method* ID */

    if (fname) {
	return ID2SYM(fname);
    }
    else {
	return Qnil;
    }
}