Created
September 1, 2016 11:57
-
-
Save nfisher/bc0ded5d6b6405f8dbe6c507c28019e9 to your computer and use it in GitHub Desktop.
Clojure Destructuring
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
;; validation of this address is managed in re-frame handler | |
(def address {:lines "15 Drury Lane" :city "London" :postcode "WC1V7AA"}) | |
(def address-component1 [address] | |
(let [lines (:lines address) | |
city (:city address) | |
postcode (:postcode address)] | |
[:dl | |
[:dt "Lines"] | |
[:dd lines] | |
[:dt "City"] | |
[:dd city] | |
[:dt "Post Code"] | |
[:dd postcode]])) | |
(def address-component2 [{lines :lines | |
city :city | |
address :address}] | |
[:dl | |
[:dt "Lines"] | |
[:dd lines] | |
[:dt "City"] | |
[:dd city] | |
[:dt "Post Code"] | |
[:dd postcode]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment