File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -529,6 +529,23 @@ pairwise constructs as found in e.g. `let` and `cond`.
529529 ... )
530530 ```
531531
532+ * <a name= " alter-var" >< /a>
533+ Use `alter-var-root ` instead of `def ` to change the value of a var.
534+ <sup> [[link]](#alter-var )< /sup>
535+
536+ ```Clojure
537+ ; ; good
538+ (def thing 1 ) ; value of thing is now 1
539+ ; do some stuff with thing
540+ (alter-var-root #'thing (constantly nil )) ; value of thing is now nil
541+
542+ ; ; bad
543+ (def thing 1 )
544+ ; do some stuff with thing
545+ (def thing nil )
546+ ; value of thing is now nil
547+ ```
548+
532549* <a name= " nil-punning" >< /a>
533550 Use `seq ` as a terminating condition to test whether a sequence is
534551 empty (this technique is sometimes called *nil punning*).
You can’t perform that action at this time.
0 commit comments