Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save noisesmith/23299a02ff7f84ed49dd4bab442a8855 to your computer and use it in GitHub Desktop.

Select an option

Save noisesmith/23299a02ff7f84ed49dd4bab442a8855 to your computer and use it in GitHub Desktop.
clojure vars are mutated, if they exist in the ns, but otherwise a new var is created
+user=> (def x 1)
#'user/x
+user=> (def the-x #'x)
#'user/the-x
+user=> (ns-unmap 'user 'x)
nil
+user=> @the-x ; the var is captured, so we can still use it
1
+user=> (def x 2)
#'user/x
+user=> @the-x ; def made a new var, old value is unchanged
1
+user=> x
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment