C
Charles L. Snyder
Hi
I am trying to solve a no doubt trivial problem
given 2 hashes of identical length, with identical keys:
h1 = {'dog'=>'blue, 'car'=>'red', boat=>'blue', 'house'=>'red',
shoe=>'green'}
h2 = {'dog'=>20, 'car' =>60, boat => 90, 'house' =>60, shoe => 70 }
I want to find the sum of the values in the second hash (the numerical
values); based on the values in the first hash:
eg
dogs are blue, and there are 20 dogs
boats are blue, and there are 90 boats
90 + 20 = 110
therefore blue => 110
cars are red, and there are 60 cars
house is red, and there are 60 houses
therefore red => 120
so the resulting hash is something like
h3 = {'blue'=>110, 'red'=>120, ...}
thanks - hopefully there is some easy way to do this I'm overlooking
CLS
I am trying to solve a no doubt trivial problem
given 2 hashes of identical length, with identical keys:
h1 = {'dog'=>'blue, 'car'=>'red', boat=>'blue', 'house'=>'red',
shoe=>'green'}
h2 = {'dog'=>20, 'car' =>60, boat => 90, 'house' =>60, shoe => 70 }
I want to find the sum of the values in the second hash (the numerical
values); based on the values in the first hash:
eg
dogs are blue, and there are 20 dogs
boats are blue, and there are 90 boats
90 + 20 = 110
therefore blue => 110
cars are red, and there are 60 cars
house is red, and there are 60 houses
therefore red => 120
so the resulting hash is something like
h3 = {'blue'=>110, 'red'=>120, ...}
thanks - hopefully there is some easy way to do this I'm overlooking
CLS