Skip to main content

join

join(delimiter: String, list: List<String>) : String

Returns the result of concatenating together the elements in list of type String using delimiter between each element.

Deprecated Bag overload

As a transitionary measure for backwards compatibility, join also accepts a Bag<String> as its second argument. Because Bags have non-deterministic ordering, the order of joined elements may be unpredictable. Convert the Bag to a List using orderBy() or order() to get deterministic results. In due time, the Bag overload will be removed and a type-checking error will be emitted instead.

Examples

join("", ["a", "b", "c"])            ==  "abc"
join(" ", ["a", "b", "c"]) == "a b c"
join(", ", ["a", "b", "c"]) == "a, b, c"
join(" and ", ["a", "b", "c"]) == "a and b and c"

See also

Types