Skip to content

Commit a4c7b78

Browse files
committed
:keys bang and friends docs
1 parent cf5240f commit a4c7b78

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

content/reference/special_forms.adoc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,14 @@ In the case of using prefixed keys, the bound symbol name is the same as the rig
332332
-> 42
333333
----
334334

335-
There are similar `:strs` and `:syms` directives for matching string and symbol keys, the latter also allowing prefixed symbol keys since Clojure 1.6.
335+
As of Clojure 1.13, map destructuring directives allow you to specify keys after `&` which will not be bound, but serve as documentation:
336+
337+
[source,clojure]
338+
----
339+
(let [{:keys [fred ethel lucy & ricky]} m] ... ;; ricky is not bound
340+
----
341+
342+
There are similar `:strs` and `:syms` directives for matching string and symbol keys, the latter also allowing prefixed symbol keys since Clojure 1.6, and support for `&` since Clojure 1.13.
336343

337344
Clojure 1.9 adds support for directly destructuring many keys (or symbols) that share the same namespace using the following destructuring key forms:
338345

@@ -352,6 +359,8 @@ Clojure 1.9 adds support for directly destructuring many keys (or symbols) that
352359
-> [1 2]
353360
----
354361

362+
As of Clojure 1.13, you can now ensure that required keys are bound during map destructuring by using the new checked variants of the `:keys`/`:syms`/`:strs` directives - `:keys!`/`:syms!`/`:strs!`, which will throw if the key is not present. Once again, the use of `&` in these checked variants will not bind names, but those keys are still checked in the destructured map.
363+
355364
[[keyword-arguments]]
356365
=== Keyword Arguments
357366

0 commit comments

Comments
 (0)