Skip to content

Instantly share code, notes, and snippets.

@devth
Created December 18, 2015 00:02
Show Gist options
  • Save devth/6f1ef853d26b75cf7250 to your computer and use it in GitHub Desktop.
Save devth/6f1ef853d26b75cf7250 to your computer and use it in GitHub Desktop.
(defprotocol F
(echo [this msg]))
(def anon (reify F (echo [this msg] (str msg " anon " this))))
(echo anon "bar")
;;=> "bar anon yetibot.core.adapters.adapter$reify__8141@6ebc46fd"
(deftype Foo [x y]
F
(echo [this msg] (str "Foo " msg this x y)))
(echo (->Foo 1 3) "hello?")
;;=> "Foo hello?yetibot.core.adapters.adapter.Foo@4db20e4c13"
(extend-type java.lang.String
F
(echo [this msg] (str "It's a String `" this "` with message: " msg)))
(echo "foo" "bar")
;;=> "It's a String `foo` with message: bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment