Skip to content

Instantly share code, notes, and snippets.

@LuminousMonkey
Created August 28, 2014 03:54
Show Gist options
  • Save LuminousMonkey/746b3519255402c2b2dd to your computer and use it in GitHub Desktop.
Save LuminousMonkey/746b3519255402c2b2dd to your computer and use it in GitHub Desktop.
;; Dynamic just means I can use the binding function with it, otherwise it will complain.
(def ^:dynamic x 11)
(defn func1
[]
(println x))
(func1) ;; Prints 11
(binding [x 22]
(func1))
;; Prints 22
(func1) ;; Prints 11
;; With the binding function, x only takes on the value within the scope of that function.
;; By default, there is no mutation possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment