Given this array:
array = ['one', 'two']
what is the best way to turn that into something like the following?
[{value: 'one', label: 'one'}, {value: 'two', label: 'two'}]
The best way is Array#map, but just to try a different way check also Enumerable#each_with_object:
array = ['one', 'two']
array.each_with_object([]) { |e, a| a << {value: e, label: e} }
#=> [{:value=>"one", :label=>"one"}, {:value=>"two", :label=>"two"}]