I'm trying to understand how let bindings work in closure in regards to maps. From my understanding let is followed by a vector where the first item is the symbol I want bound, followed by the value I want to bind it to. So
(let [a 1 b 2] a)
would give a the value of 1.
So if I declare map such as
(def people {:firstName "John" :lastName "Doe"})
And I want to bind the key firstName then this would be the correct form for a simple "Hello Person"
(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 which also works
(let [{personName :firstName} people] (str "hello " personName))
Both code snippets work and I understand why the first version works but I'm confused on the syntax on the second. Is this just syntactical sugar or a duplicate way of working and is one more idiomatic than the other?
:namein your map. - Barmar