Reputation: 5402
When using the repl, sometimes you want to destroy a variable because it somehow get in the way of your programming (most usually namespace collisions).
Is there a way to destroy a variable in clojure?
user>(def x 1)
#'user/x
user>(aggressive-destroy! x)
nil
user>x
Unable to resolve symbol: x in this context
Upvotes: 11
Views: 827
Reputation: 17257
user=> (def my-var "this is my-var!")
#'user/my-var
user=> (println my-var)
this is my-var!
nil
user=> (ns-unmap 'user 'my-var)
nil
user=> (println my-var)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: my-var in this context, compiling:(NO_SOURCE_PATH:13)
user=>
Upvotes: 18