I am having trouble with the syntax for reduce. I have a hash of the following format:
H = {\"Key1\" => 1, \"Key2\" => 2}
I would like t
Try this:
H.reduce(0) { |memo, elem| memo += elem[1] }
or
H.reduce(0) { |memo, (key, value)| memo += value }