Skip to content

Instantly share code, notes, and snippets.

@kijanowski
Created November 17, 2018 20:40
Show Gist options
  • Select an option

  • Save kijanowski/80e81f522ea0589b7649fce0e1548c73 to your computer and use it in GitHub Desktop.

Select an option

Save kijanowski/80e81f522ea0589b7649fce0e1548c73 to your computer and use it in GitHub Desktop.
// instead of
public String legacyJoin(String... args) {
return java.util.Arrays
.stream(args)
.collect(Collectors.joining(", "));
}
// do it the functional way
public String vavrJoin(String... args) {
return io.vavr.collection.List
.of(args)
.mkString(", ");
}
// or just be aware of what the JDK offers
public String stringJavaJoiner(String... args) {
return String.join(", ", args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment