From: "nobu (Nobuyoshi Nakada)" Date: 2012-04-01T08:10:28+09:00 Subject: [ruby-core:44029] [ruby-trunk - Feature #5673] undef_method probably doesn't need to raise an error Issue #5673 has been updated by nobu (Nobuyoshi Nakada). trans (Thomas Sawyer) wrote: > If we need to remove a method from a class/module that may or may not have the method defined, it's less optimal. We either have do something like: > > if instance_methods(false).include?(:foo) > undef_method(:foo) > end You can use Module#method_defined? in this case. if method_defined?(:foo) undef_method(:foo) end ---------------------------------------- Feature #5673: undef_method probably doesn't need to raise an error https://bugs.ruby-lang.org/issues/5673#change-25556 Author: trans (Thomas Sawyer) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: 2.0.0 Is there any significant reason for #undef_method to raise an error if the method is already undefined? If no, then change it to just continue on. It can return true/false to relay if was undefined vs already undefined. -- http://bugs.ruby-lang.org/