How to convert an atom to a string

any suggestions on how to convert
[mss: “Market Support Specialist”]

to this:
[{“mss”, “Market Support Specialist”}]


1 Like

Check the Atom — Elixir v1.12.3 and Enum — Elixir v1.12.3 functions :slight_smile:



iex(20)> your_atom = :ThisIsYourAtom 

# Kernel.to_string/1
iex(21)> to_string(your_atom)       

# String interpolation
iex(22)> "#{your_atom}"             
1 Like

@lc0815 orth nothing that you list will no longer be a keyword-list, therefore loosing the benefits of access syntax (ie. list[:mss]). You may consider it the possibility of converting it to a map where you can use strings as keys, if the code allows it, (also considered duplicate keys in your keywords list will be lost when converted into a map), fn {key, value} -> {to_string(key), value} end)

PS: consider what @eksperimental said.

Thank you all, found the Atom.to_string function which did the right thing for me and converted the atom to a string and solved my issue…

Thanks again… :slight_smile:

did just that and found the Atom.to_string function which worked perfectly…