Destructuring is a form of pattern matching that is common in Clojure. Destructuring allow you to pull out the specific elements from a collection.
Destructuring is commonly used with the
let method for creating local bindings (locally scoped names).
It is often the case that you will want to bind same-named symbols to the map keys. The :keys directive allows you to avoid the redundancy:
This can be written in a shorter form as follows:
As of Clojure 1.6, you can also use prefixed map keys in the map destructuring form:
As shown above, in the case of using prefixed keys, the bound symbol name will be the same as the right-hand side of the prefixed key. You can also use auto-resolved keyword forms in the :keys directive: