(deftype AnExample [field-one Int field-two Int])
; Destructure using field name
(des [(field-two field-one) (AnExample.init 1 2)]
(do
(println* field-two)
(println* field-one)))
; Destructure with rename
(des [((some-one field-two) (some-two field-one)) (AnExample.init 1 2)]
(do
(println* some-two)
(println* some-one)))
; Destructure using field order
(des [[name-one name-two] (AnExample.init 1 2)]
(do
(println* name-one)
(println* name-two)))
; Destructure multiple things
(des [[name-one name-two] (AnExample.init 1 2)
[wow-one wow-two] (AnExample.init 6 3)]
(do
(println* name-one)
(println* name-two)
(println* wow-one)
(println* wow-two)))
; Can also act like `let`
(des [example (AnExample.init 1 2)
[wow-one wow-two] (AnExample.init 6 3)]
(do
(println* example)
(println* wow-one)
(println* wow-two)))
; Don't have to use everything
(des [(field-two) (AnExample.init 1 2)]
(do
(println* field-two)))
-
Notifications
You must be signed in to change notification settings - Fork 0
TimDeve/des
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Destructuring macro for Carp
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published