Created
February 5, 2015 08:58
-
-
Save skuro/a9be817387af8b168351 to your computer and use it in GitHub Desktop.
Just a sample use of Clojure protocols
This file contains hidden or 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
(ns protocols) | |
(defprotocol Flying | |
(fly [this from to])) | |
(extend-type String ; <- protocols are "open", as they install a dispatch facility rather than fussing with type inheritance | |
Flying | |
(foo [this from to] (println "Even a String can fly from" from "to" to))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment