I have a simple array:
arr = [\"apples\", \"bananas\", \"coconuts\", \"watermelons\"]
I also have a function f that will perfo
f
Ruby 2.6.0 enables a shorter syntax by passing a block to the to_h method:
arr.to_h { |a| [a, f(a)] }