Created
June 28, 2019 10:34
-
-
Save mbuczko/6af550aa4f84146ba943849f22f556fd to your computer and use it in GitHub Desktop.
clojure / equal on type
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
(deftype Employee [name id] | |
Object | |
(equals [a b] (= (.id a) (.id b))) | |
(hashCode [this] (.hashCode (.id this))) | |
(toString [this] (.name this))) | |
(def vince (Employee. "Vince" 42)) | |
(def vincent (Employee. "Vincent" 42)) | |
(def tony (Employee. "Tony" 2)) | |
(into #{} [vince vincent tony]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment