There are two methods, hash1 and hash2, that return hashes or nil. The hashes have the same keys. I want to merge them with their mean value only if both methods have hashes.(I added Array#mean to calculate the average value of an array).def merged_hashes    return if hash1.nil? && hash2.nil?    return hash2 if hash1.nil?    return hash1 if hash2.nil?    hash1.merge(hash2) do |key, v1, v2|      [v1, v2].compact.mean    endendIs there more succinct way to write this?
Merging two hashes with the mean values of each key if both hashes exist
ruby;ruby on rails;hash table;null