Erlang Central

String Conversion To Atom

Revision as of 21:16, 18 August 2006 by Cyberlync (Talk | contribs)


You want to convert an atom to a string or vice versa


The built-in function list_to_atom converts from a string to an atom, and atom_to_list does the conversion in the other direction.

For example: 1> list_to_atom("hello").
2> atom_to_list(hello).

Note that by default Erlang is case sensitive, so the atom hello, Hello and HeLLo are unique:

1> hello = hEllo.
** exited: {{badmatch,hEllo},[{erl_eval,expr,3}]} **
2> hello = hello.