let

macrosince v0.0-927 clojure.core/letEdit
(let bindings & body)

Details:

Binds expressions to symbols and makes those symbols available only within body.

bindings should be a vector with an even number of forms, ie: [a1 b1, a2 b2, a3 b3]. The first item in a pair (the as) should be a symbol that is assigned the evaluation of the second item (the bs). These symbols (the as) are then available within body (and not outside of body).

Another way to think about this is that the binding symbols in let are like local defs that are only available within let's scope.

In addition to direct symbol binding, let supports a destructuring syntax to "break apart" collections into multiple symbols. This destructuring syntax is like it's own mini-language and allows for succinct code.

let is a wrapper over one of ClojureScript's special forms and is a fundamental building block of the language. Many macros rely on lets binding syntax and scope rules.


See Also:


Source docstring:
binding => binding-form init-expr
binding-form => name, or destructuring-form
destructuring-form => map-destructure-form, or seq-destructure-form

Evaluates the exprs in a lexical context in which the symbols in
the binding-forms are bound to their respective init-exprs or parts
therein.

See https://clojure.org/reference/special_forms#binding-forms for
more information about destructuring.
Source code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro let
  [bindings & body]
  (assert-args let
     (vector? bindings) "a vector for its binding"
     (even? (count bindings)) "an even number of forms in binding vector")
  `(let* ~(destructure bindings) ~@body))