From: Todd Benson Date: 2007-07-14T21:45:43+09:00 Subject: Re: attr_writer and hash On 7/14/07, aidy wrote: > Hi, > > class Test > attr_writer :username, :password > def initialize > h = {:username => 'user', :password => 'pass'} > end > end > > t = Test.new > p t.h[username] > > > I am trying to access a hash key after instantiating the Test class, > but I am having a slight problem. > > Could someone please direct me? > > Thanks > > Aidy class Test attr_accessor :h def initialize @h = { :username => 'user', :password => 'pass } end end attr_accessor means you can read and write to the object. The object in this case is the hash, not the key or value. Does that make sense? hth, Todd