I want to convert the array of this:
["Cyan", "Magenta", "Yellow", "Black"]
to hash like this:
{1 => "Cyan", 2 => "Magenta", 3 => "Yellow", 4 => "Black"}
How could I make it in Ruby language?
I've tried using this code
color = ["Cyan", "Magenta", "Yellow", "Black"]
var.each_with_object({}) do |color_hash|
color_hash
end
But i've got error. What is the correct code for that?