W
walter
Ok,
ALthough the docs don't mention it, Hash comparison using == checks
not only the key value pairs, but also the default value / default
procs.
So how does one compare 2 hashes key-value pairs. I can see that it
might be useful to distinguish between 2 hashes whose key-value pairs
are the same but the default value/default proc are different, but I
would think that would be much less often than wanting to know if the
key-value pairs are the same.
Maybe I am thinking about this all wrong, but I always viewed a Hash
as a Hash, and yes some might have a default value and some might
have a default proc, but it is the data (the key-value pairs) that,
to me, make up the Hash. The default data/procs are convenience that
make it easier to work with a Hash, but I would think that {} and
Hash.new(3) would be == if their key-value pairs would be equal.
Assuming that I am in the minority here about ==, what is the proper
way to see if 2 Hashes key-value pairs are the same.
Walt
*****************************************************
Walter Szewelanczyk
IS Director
M.W. Sewall & CO. email : (e-mail address removed)
259 Front St. Phone : (207) 442-7994 x 128
Bath, ME 04530 Fax : (207) 443-6284
*****************************************************
ALthough the docs don't mention it, Hash comparison using == checks
not only the key value pairs, but also the default value / default
procs.
So how does one compare 2 hashes key-value pairs. I can see that it
might be useful to distinguish between 2 hashes whose key-value pairs
are the same but the default value/default proc are different, but I
would think that would be much less often than wanting to know if the
key-value pairs are the same.
Maybe I am thinking about this all wrong, but I always viewed a Hash
as a Hash, and yes some might have a default value and some might
have a default proc, but it is the data (the key-value pairs) that,
to me, make up the Hash. The default data/procs are convenience that
make it easier to work with a Hash, but I would think that {} and
Hash.new(3) would be == if their key-value pairs would be equal.
Assuming that I am in the minority here about ==, what is the proper
way to see if 2 Hashes key-value pairs are the same.
Walt
*****************************************************
Walter Szewelanczyk
IS Director
M.W. Sewall & CO. email : (e-mail address removed)
259 Front St. Phone : (207) 442-7994 x 128
Bath, ME 04530 Fax : (207) 443-6284
*****************************************************