Skip to content

Instantly share code, notes, and snippets.

@nfisher
Created September 1, 2016 11:57
Show Gist options
  • Save nfisher/bc0ded5d6b6405f8dbe6c507c28019e9 to your computer and use it in GitHub Desktop.
Save nfisher/bc0ded5d6b6405f8dbe6c507c28019e9 to your computer and use it in GitHub Desktop.
Clojure Destructuring
;; 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