Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a function from the lein repl?

During a lein REPL session, I may define a number of functions. However, sometimes I would want the session to 'forget' them - for example when I execute (run-all-tests), this highlights failures from tests that I no longer need. Is there a way to remove functions from the session, or to clean it, without restarting?

like image 987
Rich Ashworth Avatar asked Mar 25 '13 23:03

Rich Ashworth


People also ask

How do I get out of Lein REPL?

You can exit the REPL by typing Ctrl+D (pressing the Ctrl and D keys at the same time).

What is clojure Main?

The clojure. main namespace provides functions that allow Clojure programs and interactive sessions to be launched via Java's application launcher tool java .


1 Answers

use ns-unmap as described on the Clojure namespaces page http://clojure.org/namespacesuser>

(defn foo [x] (inc x))                    
#'user/foo     
user> (foo 3)       
4                                                                                
user> (ns-unmap *ns* 'foo)     
nil
user> (foo 3)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:1:1) 
like image 89
Arthur Ulfeldt Avatar answered Oct 10 '22 20:10

Arthur Ulfeldt