Noobie question :)
How to transform a list data structure into a string in Elixir?
Examples:
["all"] # into "['all']"
["project", "labels"] # into "['project', 'labels']"
Noobie question :)
How to transform a list data structure into a string in Elixir?
Examples:
["all"] # into "['all']"
["project", "labels"] # into "['project', 'labels']"
I do not claim the only right decision but maybe this will be helpful:
iex(13)> a = ['project', 'labels']
['project', 'labels']
iex(14)> b = inspect a
"['project', 'labels']"
But for double quoted srting:
iex(21)> c = ["all"]
["all"]
iex(22)> d = inspect(c) |> String.replace("\"", "'")
"['all']"
Because "all"
is a binary, but 'all'
is a char_list. From here