In Ruby, why is it not enough to alias `method_missing` to catch call to undefined methods?


In Ruby, why is it not enough to alias `method_missing` to catch call to undefined methods?



That seems all the more unexpected when defining a dummy method passing all arguments do the job. That is the following works:


def method_missing(ago, *lokatoj, &bloko)
mistrafe(ago, *lokatoj, &bloko)
end

def mistrafe(ago, *lokatoj, &bloko)
# faru ion
end



While the following doen't


alias mistrafe method_missing



Why is that so?




1 Answer
1



alias mistrafe method_missing does not work because the syntax of alias is:


alias mistrafe method_missing


alias


alias OLD_NAME NEW_NAME



That said, the following will work:


alias method_missing mistrafe






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined