From: Rolf Pedersen Date: 2011-02-05T01:03:11+09:00 Subject: Re: Setter method for Hash value --00163646bf508928aa049b7703e7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Jesus It does seem to be working. At least the example "requirements" that I defined does give the expected response. I have to admit, I need to study this a bit, to figure out HOW it is working, though. ;o) I will try to incorporate this into the actual code now, and check if it still holds. Thanks. Best regards, Rolf 2011/2/4 Jes=FAs Gabriel y Gal=E1n > What about this: > > class MyClass > def props > @props =3D DataClass::get_props() > Props.new @props > end > > def props=3D(h) > DataClass::set_props h > end > end > > class Props > def initialize h > @h =3D h > end > > def [](key) > DataClass::get_prop key > end > > def []=3D(key,value) > DataClass::set_prop key,value > end > > def inspect; @h.inspect; end > def to_s; @h.to_s; end > end > > > class DataClass > @@data =3D {:a=3D>1, :b=3D>2, :c=3D>3} > def self.get_props() > @@data > end > def self.get_prop(key) > @@data[key] > end > def self.set_props(data) > @@data =3D data > end > def self.set_prop(key, value) > @@data[key] =3D value > end > end > > > Jesus. > > --00163646bf508928aa049b7703e7--