Suggest how to convert list to string with a character

Hi, I have a list which includes some string or integer item that I need to convert it to string with a character like “/”, then I used Enum.map like bottom code.

Enum.map(["a", "b", "c"], fn x -> "#{x}/" end) |> List.to_string

But I need to know is there a way which does not use loop like Enum.map for example

Enum.map(["a", "b", "c"], fn x -> "#{x}/" end) |> List.to_string("/")

Thanks

1 Like

not sure what you want, but it seems like you are looking for

iex(1)> Enum.join(["a", "b", "c"], "/")
"a/b/c"
4 Likes

If you are building path, not just joining the strings, then you should use Path.join/1 instead.

6 Likes