Created
July 9, 2015 15:07
-
-
Save pjstadig/3215c5febf4861341c05 to your computer and use it in GitHub Desktop.
MultiFn does not implement java.util.Comparator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clojure 1.6.0 | |
user=> (defmulti cmp (fn [a b] [(class a) (class b)])) | |
#'user/cmp | |
user=> (defmethod cmp :default [a b] (compare a b)) | |
#<MultiFn clojure.lang.MultiFn@1da5688d> | |
user=> (sort cmp [:b :a]) | |
ClassCastException clojure.lang.MultiFn cannot be cast to java.util.Comparator clojure.core/sort (core.clj:2829) | |
user=> (sort (fn [a b] (cmp a b)) [:b :a]) | |
(:a :b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment