From: "Abinoam Jr." Date: 2012-01-21T13:00:44+09:00 Subject: Re: Getting an Object to Push or Register "Itself" With a Hash During Initialization On Sat, Jan 21, 2012 at 12:30 AM, Frank Guerino wrote: > This seems to work! > > > class Color >  def initialize (address, color, colorHash) >    @localColor = color >    @localAddress = address >    #colorHash[@localAddress].push(self) >    colorHash.store(@localAddress, self) >  end > >  def getColor >    @localColor >  end > end > > hashObject = {} > > 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] = 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.