undef - Why would you want to undefine a method in ruby?

前端 未结 7 623
无人共我
无人共我 2020-12-15 09:41

I\'ve never seen undef - or any thing else that allows you to undefine a method - in any other programming languages. Why is it needed in Ruby?

EDIT: I\'m not arguin

7条回答
  •  [愿得一人]
    2020-12-15 10:25

    You can look at all of Rails for examples of defining methods at runtime (aka metaprogramming). By calling one method in your class definition, it can define a whole bunch of methods for all instances of that class...

提交回复
热议问题