How To Join String In Elixir
There’s some way to join your string in Elixir, here they’re :
Using Enum.join
Let’s assume we have 2 string value:
str1 = "hello" str2 = "programmer"
you can join them with Enum.join:
iex(4)> Enum.join([str1, str2]) "helloprogrammer" # join with string between them iex(5)> Enum.join([str1, str2], " ") "hello programmer" # Enum.join with pipeline iex(6)> [str1, str2] |> Enum.join "helloprogrammer" # Enum.join pipeline with separator iex(7)> [str1, str2] |> Enum.join(" ") "hello programmer"
String interpolation
iex(8)> "#{str1} #{str2}" "hello programmer"
Using “<>” operator
iex(9)> str1 <> " " <> str2 "hello programmer"
Thats all.. Finish, happy coding..
Comment please if you have another way..