Skip to content

Commit 0ad4c33

Browse files
committed
swapping extended :all example into guide
1 parent 243dc2e commit 0ad4c33

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

content/guides/destructuring.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,21 @@ To get a map like the input map with defaults substituted for missing keys, use
381381
-> [42 {:a 42, :b 3}]
382382
----
383383

384+
When using `:all`, defaults are applied at every nested level that contains an `:or` directive.
385+
386+
[source,clojure]
387+
----
388+
(let [nested-map {:a 1, :nested {:aa 10}}
389+
390+
{:keys [a & :b] :as m :or {:a 42 :b 3} :all all-m
391+
{:keys [aa bb] :or {:bb 30}} :nested}
392+
nested-map]
393+
all-m)
394+
395+
396+
-> {:a 1, :b 3, :nested {:bb 30, :aa 10}}
397+
----
398+
384399
Associative destructuring can be nested and combined with sequential destructuring as needed.
385400

386401
[source,clojure]

content/reference/special_forms.adoc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,6 @@ To get a map like the input map with defaults substituted for missing keys, use
391391
-> [42 {:a 42, :b 3}]
392392
----
393393

394-
Defaults are applied at every nested level that contains an `:or` directive.
395-
396-
[source,clojure]
397-
----
398-
(let [nested-map {:a 1, :nested {:aa 10}}
399-
400-
{:keys [a & :b] :as m :or {:a 42 :b 3} :all all-m
401-
{:keys [aa bb] :or {:bb 30}} :nested}
402-
nested-map]
403-
all-m)
404-
405-
406-
-> {:a 1, :b 3, :nested {:bb 30, :aa 10}}
407-
----
408-
409394
[[keyword-arguments]]
410395
=== Keyword Arguments
411396

0 commit comments

Comments
 (0)