Grooviest way to join collection of Strings in Groovy 2.x
groovy, join, string
Solution
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(",")
Problem
I just tried: ``` List<String> values = getSomehow() values.join(",") ``` But see that `join` has been deprecated as of 2.1. So I ask: How should I be writing this in accordance with the latest preferred/non-deprecated syntax? Also, is there a way to accomplish this with closures? I feel like I could be utilizing `collect()` or something similar here.