Hi,

At Wed, 9 Feb 2005 15:20:07 +0900,
David McCabe wrote in [ruby-talk:130214]:
> In python, my parser returns a hash of unit_type objects, where the
> names of units are the keys. Each time a unit is instantiated, it
> receives a unit_type object as an argument. Now here's the interesting
> part: it copies the instance variables from the unit_type into itself.
> 
> class Unit(object):
>       def __init__(self, type):
> 	  self.type = type
> 	  self.__dict__.update(self.type.__dict__)
> 
> There's more to it than that, but that's the interesting part. So now
> I can say:
> 
>       my_new_unit = Unit(types["Panzer"])
> 
> And I'll get a Unit object with all the values for Panzers
> initialized.

What about:

  module Unit
  end

  my_new_unit = types["Panzer"].extend(Unit)

-- 
Nobu Nakada