%{
type: 11,
foo: “bing”,
bar: “bang”,
baz: “bop”
}
I want to transform the value of the type key with a string depending on what the integer is.
For instance, if the integer is 11, the value would become “Red” in the new map. If the integer is 14, the value would become “Blue”. The rest of the key-value pairs in the map should remain untouched.
%{
type: “Red”,
foo: “Bing”,
bar: “Bang”,
baz: “Bop”
}
I’m pretty new to Elixir so I’m still trying to get my head around a lot of the concepts. I’ve tried creating a function with a new map where each integer corresponds to a particular key but I don’t understand how to utilize this new map.
def convert_integer_to_string(map) do
%{
1 => map[“Red”]
11 => map[“Blue”]
13 => map[“Orange”]
}
end