class A < Array
  def self.hide(name)
    if instance_methods.include?(name.to_s) and name !~ /^__|instance_eval/
      undef_method name
    end
  end
  instance_methods.each {|m| p "deleted #{m}"; hide(m)}
end
a = A.new
a = [1,2,3]
a.each {|i| p i}
执行之后,那些方法都没有被删除 代码是根据《元编程》第 64 页 改的,望有高手指点!--非常感谢!