I have an array of hashes for instance:
array = [{apple => 10},{banana => 5},{pear => 1}] I want to do something like the following (partly pseudocode)
fruit = "Orange" if array.anyhash.key = fruit do |fruit| array << {fruit => 1} else array.hashwithkey(fruit).value += 1 end Is there a way to do this simply or do I have to do nested each statements?