Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defprotocol AProtocol
- (say-hello [this])
- (location [this]))
- (defrecord Place [name])
- (extend-protocol AProtocol
- Object
- (say-hello [this] (str "Hello " (location this)))
- Place
- (location [this] (str (:name this))))
- (defrecord HappyPlace [name])
- (extend-protocol AProtocol
- HappyPlace
- (say-hello [this] (str "HELLO " (location this) "!"))
- (location [this] (str (:name this))))
- (say-hello (Place. "World"))
- ;; No implementation of method: :say-hello of protocol: #'user/AProtocol found for class: user.Place
- ;; [Thrown class java.lang.IllegalArgumentException]
Add Comment
Please, Sign In to add comment