Skip to content

Instantly share code, notes, and snippets.

@peter
Last active August 13, 2017 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter/bdaac5cd713595ffe3eb to your computer and use it in GitHub Desktop.
Save peter/bdaac5cd713595ffe3eb to your computer and use it in GitHub Desktop.
Readability of Clojure vs Java 8 Streams

Java:

public Optional<String> getType() {
    return this.types.isEmpty() ?
        Optional.empty() :
        Optional.of(String.join(",", (Iterable)this.types.stream().map(Enum::name).collect(Collectors.toList())));
}

Clojure:

(defn type [self]
  (not-empty (str/join "," (map :name (:types self)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment