From: Simon Strandgaard Date: 2004-04-15T23:34:10+09:00 Subject: Re: Hash == not always working? Or am I missing something? On Fri, 16 Apr 2004 00:07:55 +0900, walte wrote: > I am having difficulty with Hash and sometimes Arrays with ==. Below > is an example with Hashes. I am trying to do some simple cleanup of > our data and was trying TDD some code but I do not understand why it > says my 2 Hashes are different. They appear identical but show up as > false using ==. > I see you make usage of #default_proc.. but the Hash you compare against does't contains a equal #default_proc. server> ri Hash.default_proc ------------------------------------------------------ Hash#default_proc hsh.default_proc -> anObject ------------------------------------------------------------------------ If +Hash::new+ was invoked with a block, return that block, otherwise return +nil+. h = Hash.new {|h,k| h[k] = k*k } #=> {} p = h.default_proc #=> # a = [] #=> [] p.call(a, 2) a #=> [nil, nil, 4] server> -- Simon Strandgaard