Hallo,

On Thu, 6 Jun 2002 13:57:14 +0200, Christoph <chr_news / gmx.net> wrote:
> > class A
> >  def initialize(name)
> >     type.send(:attr_accessor,name)
> >     send("#{name}=",name)
> >   end
> > end
> >
> > mamas = A.new('cat')
> > papas = A.new('dog')
> 
> p papas.cat   # => nil
> p mamas.dog   # => nil
> 
> > class A
> >  def initialize(name)
> >     class << self; self end.send(:attr_accessor,name)
> >     send("#{name}=", name)
> >   end
> > end
> >
> > mamas = A.new('cat')
> > papas = A.new('dog')
> 
> p papas.cat  #
> p mamas.cat   #
> # both raise a non-method error since cat and dog are
> # singleton methods of mama and papa respectively.

mamas.cat returns "cat" while mamas.dog raises a non-method error.

But I have to admit that this approximation was much better than
the previous one!  ;-)

It probably wasn't deliberate but it was very good paedagogically.
You mail made me to actually try these examples :-)

Thank you for lovely example.

Stepan