如何在Clojure中取消定义函数? [英] How can I undefine a function in Clojure?

查看:141
本文介绍了如何在Clojure中取消定义函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我需要在clojure中定义一个函数。

解决方案

如果你有:

 (def x 42)

可能有助于解除绑定var:

 (。unbindRoot#'x)



现在,如果您尝试此

  x 

您将获得:

 #< Unbound Unbound:#'user / x> 


Often I need to undefine a function in clojure. If I define something with defn how can I undefine it?

解决方案

If you have:

(def x 42)

It might be useful to unbind the var:

(.unbindRoot #'x)

Now, if you try this

x

You get:

#<Unbound Unbound: #'user/x>

这篇关于如何在Clojure中取消定义函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆