None
Usage
The Hash#diff method is helpful for determining the difference between two hashes.
note: The receiver matches on both keys and values. If the pair is not matched it be returned. (for example: {:a => 1, :b => 3}.diff({:a=>2}) # => {:a=>1, :b=>3})
Test
unit_tests do
test "find the difference between two hashes" do
assert_equal({:b=>3}, {:a => 1, :b => 3}.diff({:a=>1}))
end
end
The behavior with disjunct hashes deserves a test, too.
ReplyDeletetest "find the difference between two disjunct hashes" do
assert_equal({:a => 1, :x => 100}, {:a => 1}.diff({:x => 100}))
end
Yep, definitely handy for testing.
ReplyDelete