I tried looking through this Ruby documentation, but have no idea why I would want to store a function as a content of the hash.
Thanks in advance for your explanations!
def find_city(map, state)
if map.include? state
return map[state]
else
return "Not found."
end
end
cities[:find] = method(:find_city)
When you wanted to look up a proc by a key.
This might be used, for example, as a simple command pattern implementation.
As to your example, without knowing what
citiesis, or having any more context, it’s impossible to say what the purpose is.