Files
linguist/samples/Clojure/protocol.cljs
2013-11-05 15:33:05 +07:00

16 lines
233 B
Clojure

(defprotocol ISound (sound []))
(deftype Cat []
ISound
(sound [_] "Meow!"))
(deftype Dog []
ISound
(sound [_] "Woof!"))
(extend-type default
ISound
(sound [_] "... silence ..."))
(sound 1) ;; => "... silence ..."