Tracks
/
Clojure
Clojure
/
Syllabus
/
Sequential Destructuring
Se

Sequential Destructuring in Clojure

1 exercise

About Sequential Destructuring

Clojure's sequential destructuring syntax is a concise way to extract values from a vector and assign them to distinct variables.

In this example, each value in the number-of-moons vector is assigned to its corresponding planet:

(def number-of-moons [0 2 14])

(let [[venus mars neptune] number-of-moons]
  neptune)

;=> 14
Edit via GitHub The link opens in a new window or tab

Learn Sequential Destructuring