On Sat, Jan 21, 2012 at 12:30 AM, Frank Guerino <frank.guerino / if4it.com> w=
rote:
> This seems to work!
>
>
> class Color
> =A0def initialize (address, color, colorHash)
> =A0 =A0@localColor =3D color
> =A0 =A0@localAddress =3D address
> =A0 =A0#colorHash[@localAddress].push(self)
> =A0 =A0colorHash.store(@localAddress, self)
> =A0end
>
> =A0def getColor
> =A0 =A0@localColor
> =A0end
> end
>
> hashObject =3D {}
>
> Color.new( "A", "Red", hashObject )
> Color.new( "B", "White", hashObject )
> Color.new( "C", "Blue", hashObject )
>
> puts hashObject["C"].getColor
> puts hashObject["B"].getColor
> puts hashObject["A"].getColor
>
>
> Thanks!
>
> Frank
>
> --
> Posted via http://www.ruby-forum.com/.
>

Hi Frank,

Try...

colorHash[@localAddress] =3D self

About the...

homeHash[@localHomeAddressString].push(self)

1) Hash doesn't have any 'push' method (this is for Array).
2) homeHash[@localHomeAddressString] is probably returning 'nil'
because this key doesn't have any value associated with it. After
that, ruby tries to send 'push' method to this returned object.

Abinoam Jr.