Should I use alias or alias_method?

后端 未结 7 1733
再見小時候
再見小時候 2020-11-30 16:25

I found a blog post on alias vs. alias_method. As shown in the example given in that blog post, I simply want to alias a method to another within t

7条回答
  •  自闭症患者
    2020-11-30 16:59

    alias_method new_method, old_method

    old_method will be declared in a class or module which is being inherited now to our class where new_method will be used.

    these can be variable or method both.

    Suppose Class_1 has old_method, and Class_2 and Class_3 both of them inherit Class_1.

    If, initialization of Class_2 and Class_3 is done in Class_1 then both can have different name in Class_2 and Class_3 and its usage.

提交回复
热议问题