Created
October 29, 2013 03:42
-
-
Save jebberjeb/7208877 to your computer and use it in GitHub Desktop.
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
(ns test-app.core) | |
(defprotocol Fooable | |
(foo [this f]) | |
(bar [this b])) | |
(deftype FooPrinter [] | |
Fooable | |
(foo [this f] (println "foo: " f)) | |
(bar [this b] (println "bar: " b))) | |
(foo (FooPrinter.) 3) | |
(extend java.lang.String | |
Fooable | |
{:foo (fn [this f] (str this " foo: " f)) | |
:bar (fn [this b] (str this " bar: " b))}) | |
(println (foo "a string" 3)) | |
(extend clojure.lang.PersistentArrayMap | |
Fooable | |
{:foo (fn [this f] (assoc this :foo f)) | |
:bar (fn [this b] (assoc this :bar b))}) | |
(println (foo {:bar "bar" :baz "baz"} "foozle")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment