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 want to get what is the difference between two hashes, you can do this:
h1 = {:a => 20, :b => 10, :c => 44} h2 = {:a => 2, :b => 10, :c => "44"} result = {} h1.each {|k, v| result[k] = h2[k] if h2[k] != v } p result #=> {:a => 2, :c => "44"}