How to convert an atom to a string

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

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

thanku

1 Like

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

2 Likes

or…

iex(20)> your_atom = :ThisIsYourAtom 
:ThisIsYourAtom

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

# String interpolation
iex(22)> "#{your_atom}"             
"ThisIsYourAtom"
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)

Enum.map(keywords, 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…