When using interpolation, inside single quotes, the contents of the Elixir CharList (Erlang string) are internally represented as an Elixir String (Erlang binary) and only become a CharList at the end with a hidden call to String.to_char_list/1
that you can see in the quoted form, so any CharList with interpolation can be written directly as a String.to_char_list(string_with_interpolation)
instead for the same quoted form.
When :
is added before either the CharList or the String, the quoted form is the same (the only difference is due to the single or double quotes around the interpolated bar
). This can be thought of as either (a) quotes for atoms don't have the same meaning as they do normally or (b) when single quotes are used, the String.to_char_list/1
call is stripped when wrapped in the :erlang.binary_to_atom/1
call.