I have an array of arrays that looks like this:
fruits_and_calories = [
["apple", 100],
["banana", 200],
["kumquat", 225],
["orange", 90]
]
I also have a method I want to invoke on each element of the array:
fruits_and_calories.each do |f| eat(f[0], f[1])
I'd really like to be able to say something like:
fruits_and_calories.each do |f| eat(f[:name], f[:calories])
Is there a way that I can pull this off without having to change each item in the array (for example, by iterating through it and somehow adding the symbols in)? Or, if that's too hard, is there a better alternative?