"Brian Candler" <B.Candler / pobox.com> schrieb im Newsbeitrag
news:20030604181446.GA1523 / uk.tiscali.com...
> On Thu, Jun 05, 2003 at 01:57:32AM +0900, Daniel Berger wrote:
> > Let's say I have a class:
> >
> > class Foo
> >    attr_reader :val1, :val2
> >    def initialize
> >       @val1 = "hello"
> >       @val2 = "world"
> >    end
> > end
> >
> > Then, let's say I have a subclass of Foo, and I want to remove the
> > "val1" method.  How would I do it?
>
> Well there's always:
>
>   class Bar
>     def val1
>       raise NameError
>     end
>   end
>
> i.e. replace val1 an explicit 'I do not exist' method. Otherwise it will
be
> inherited.

Wouldn't it be better to do

class Bar
  def val1
    method_missing :val1
  end
end

This would delegate to the default handling of missing methods.  This would
keep the scheme if there was another sub class of Bar that want's to deal
with all missing method by itself.

Regards

    robert