Skip to content

Instantly share code, notes, and snippets.

@viebel
Last active November 26, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viebel/2b8f5ebe471c991e88710837d83d3a51 to your computer and use it in GitHub Desktop.
Save viebel/2b8f5ebe471c991e88710837d83d3a51 to your computer and use it in GitHub Desktop.
Protocol and records in a DO compliant way
(defprotocol FullName
(full-name [person]))
(defrecord AuthorEncapsulation [firstname lastname]
FullName
(full-name [author] (str (:firstname author)
" "
(:lastname author))))
(defrecord AuthorData [firstname lastname])
(extend-protocol FullName
AuthorData
(full-name [author] (str (:firstname author)
" "
(:lastname author))))
(full-name (AuthorData. "Isaac" "Asimov"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment