On 2004-04-15 23:07:55 +0900, walter / mwsewall.com 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 ==. You compare a hash created with a block argument to a hash created without a block argument. That's why they are not equal. Actually it's complicated to compare such hashes. You can implement a workaround like that: $block = lambda {|h,k| h[k] = 0} hash1 = Hash.new(&$block) hash2 = Hash.new(&$block) Perhaps it would be easier to just use hash = Hash.new(0) for your hashes. -- c, s, x = gets, c[0, 2].to_i, "dsfd;kfoA,.iyewrkldJKDHSUB" puts (1...(c.size / 2)).inject("") do |p, i| p << (c[2 * i, 2].to_i(16) ^ x[(s += 1) && s -1]) end