I am trying to figure out how to tie closure bindings to cards. From my understanding, let there be a vector in which the first element is the symbol that I want to associate, followed by the value to which I want to associate it. So,
(let [a 1 b 2] a)
will give a value of 1.
So, if I declare a map, for example
(def people {:firstName "John" :lastName "Doe"})
And I want to bind the key firstName, then it will be the correct form for a simple "Hello man"
(let [personName (:firstName people)] (str "hello " personName))
This works, however, on the Clojure website http://clojure.org/special_forms#binding-forms they show a different form that also works
(let [{personName :firstName} people] (str "hello " personName))
Both code snippets work, and I understand why the first version works, but I got confused in the second syntax. Is it just syntactic sugar or a duplicate way of working and is another idiomatic than another?
source share