I have array of arrays like this:
status = [
["Deleted", "deleted", 0],
["In planning", "planning", 1],
["In approval", "approval", 2]
]
How do I transform it to an array of hashes like this?
[
{:label => "Deleted", :value => "deleted"},
{:label => "In planning", :value => "planning"},
{:label => "In approval", :value => "approval"}
]
So far I tried:
status.each do |s| label: s[0], value: s[1] end
However, I don't get back an array of hashes. If I do:
puts s[0], value: s[1]
I see only hashes in my console:
{:label => "Deleted", :value => "deleted"}
{:label => "In planning", :value => "planning"}
{:label => "In approval", :value => "approval"}
I believe I somehow would need to add those hashes to the array.
status.map { |s| {label: s[0], value: s[1]} }.map