Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created August 12, 2013 09:38
Show Gist options
  • Save frenchy64/6209533 to your computer and use it in GitHub Desktop.
Save frenchy64/6209533 to your computer and use it in GitHub Desktop.
extenders ignores datatypes
(defprotocol PMaths
(mult-by-two [this]))
(defrecord SpecialNumber [x]
PMaths
(mult-by-two [this] (assoc this :x (* (:x this) 2))))
(extend-protocol PMaths
nil
(mult-by-two [this])
String
(mult-by-two [this]))
(extenders PMaths)
;=> (U nil java.lang.String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment