You can use the Iterator
variation of the join
method in DefaultGroovyMethods
. It’s signature is the same, only the separator needs to be passed in.
It would look like this:
List<String> values = ["string1", "string2", "string3"]
String joinedValues = values.join(",")
Or you can do it all on one line:
String joinedValues = ["string1", "string2", "string3"].join(",")