Possible duplicate:
undef - Why do you want to uninstall a method in ruby?
Can anyone lay out a practical use for undef in ruby? I come from languages ββlike javascript and python that do not have built-in. Of course, you can imitate it in a language such as javascript:
var obj = { func:function(){alert("works")} } obj.func()
but I never used to do this. Are there any general situations where undef is really useful?
EDIT - Just came across this in the Ruby Programming Language book:
Another way to prevent objects from copying is to use undef to simply remove the cloning and duplication methods. Yet another approach is to override clone and duplicate so that they throw an exception with an error message that specifically states that copies are not allowed. Such an error message may be useful for programmers who use your class.
source share