Destructuring

Learn how to access the information in complex data structures by binding names to the values inside of the structures.

What is destructuring?

Destructuring is probably one of the most unique concepts that Clojure offers because we can't compare it to anything we know in other languages. It’s a very powerful and useful tool that allows us to make better code and leave it in a much more functional programming style with a reduced number of lines.

Destructuring is the ability to bind names or symbols to the values inside of a data structure without having to access those values. It’s most common with collections. Let’s see some examples before getting into its explanation.

Destructuring of lists, vectors, and sequences

This is also known as sequential destructuring. Let's see an example:

Get hands-on with 1200+ tech skills courses.