Getting alias name within method

I’d like to do:

def one
puts method

alias :two :one

=> one
=> two

However, both print “one”.

My idea was to define several similar methods this way, as an
alternative to using a eval loop (which works). This is much like the
“$0” in a shell script. If the program is aliased, you get the alias
(name by which it was called).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs