An array format is like following(the values won't duplicated in the array):
["ID", nil, "MO"]
I want to remove the nil, but the hash values should store the index in original array. Expected result:
{
"ID" => 0,
"MO" => 2
}
How could I do it in an elegant way?