From: Yossef Mendelssohn Date: 2010-12-02T04:27:22+09:00 Subject: Re: hash method how-to? On Dec 1, 1:10 pm, niklas | brueckenschlaeger wrote: > http://en.wikipedia.org/wiki/Hash_function > > in most cases it's the easiest to delegate the hash method to something > else. Example: > > class X >   def initialize(name) >     @name = name >   end > >   def hash >     @name.hash >   end > end > > h = { X.new("foo") => "bar" } > h[X.new("foo")] = "baz" # will overwrite the above And so will `h['foo'] = 'baz'`. -- -yossef