I am trying to compare two Ruby Hashes using the following code:
#!/usr/bin/env ruby
require \"yaml\"
require \"active_support\"
file1 = YAML::load(File.op
If you need a quick and dirty diff between hashes which correctly supports nil in values you can use something like
def diff(one, other)
(one.keys + other.keys).uniq.inject({}) do |memo, key|
unless one.key?(key) && other.key?(key) && one[key] == other[key]
memo[key] = [one.key?(key) ? one[key] : :_no_key, other.key?(key) ? other[key] : :_no_key]
end
memo
end
end