What is faster on later invocation:
def first_method?() second_method?() end
alias_method :first method, :second_method
and if possible why?
(NOTE: I don’t ask what is nicer / better etc. -> only raw speed and why it is faster is interesting here)
a quick look at the source code, will show you the trick:
alias_method is written in C. moreover, defining a method in ruby that calls another method, will result in 2 method lookups and calls.
so, alias_method should be faster.
Answered By – Andrea Pavoni
Answer Checked By – David Marino (BugsFixing Volunteer)