Last active
November 26, 2020 14:32
-
-
Save viebel/2b8f5ebe471c991e88710837d83d3a51 to your computer and use it in GitHub Desktop.
Protocol and records in a DO compliant way
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
(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