The join()
method of the Enum
module is used to join the given enumerable to a string with a separator.
Enum.join(enumerable, joiner \\ "")
enumerable
: The enumerable/list of strings.joiner
: The separator string used for joining the strings.The method returns a string.
lst = ["hello", "educative", "answers"]joiner = " -- "joined_string = Enum.join(lst, joiner)IO.inspect lstIO.puts "separator: #{joiner}"IO.puts "--------"IO.puts "Joined string from the list -"IO.puts joined_string
Enum.join()
method.Free Resources