Skip to content

Instantly share code, notes, and snippets.

@skuro
Created February 5, 2015 08:58
Show Gist options
  • Save skuro/a9be817387af8b168351 to your computer and use it in GitHub Desktop.
Save skuro/a9be817387af8b168351 to your computer and use it in GitHub Desktop.
Just a sample use of Clojure protocols
(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