Name

alias Statement

Synopsis

alias new old

Creates an alias new for an existing method, operator or global variable, specified by old. This functionality is also available via Module#alias_method. When making an alias of a method, it refers the current definition of the method.

def foo
  puts "foo!"
  end
alias foo_orig foo
def foo
  puts "new foo!"
end
foo                 # => "new foo!"
foo_orig            # => "foo!"

Get Ruby in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.