Hi,

In message "[ruby-talk:14520] alias, undef, etc."
    on 01/05/02, "Hal E. Fulton" <hal9000 / hypermetrics.com> writes:

|Pardon my ignorance, but what is going on
|with alias and alias_method? Is the former
|deprecated or something?
|
|Same with undef. Where is it defined/documented?

They are documented in syntax.html in the reference, and "alias" is
explained in p.232 of the pickaxe book.  "undef" is not covered by the
book accidentally.  Well, I think it is ALMOST perfect.

|And what is the difference between undef and
|remove_method?

remove_method removes particular implementation in the class/module,
whereas undef makes a method disappear.  For example,

  class Foo
     def zzz
       puts "Foo"
     end
  end

  class Bar<Foo
    def zzz
       puts "Bar"
    end
  end

  foo = Foo.new
  foo.zzz       #=> Foo
  bar = Bar.new
  bar.zzz       #=> Bar

  class Bar
    remove_method :zzz  # remove Bar#zzz, but Foo#zzz remains
  end

  bar.zzz       # => Foo
  class Bar
    undef zzz   # zzz is not defined anymore
  end

  foo.zzz       #=> Foo -- class Foo is not affected
  bar.zzz       # undefined; Error!

You can see also p.352 of the pickaxe book, or "ri undef_method".


							matz.