groovy初学者 - 如何从groovy shell中的内存中删除变量

Arv*_*ind 5 groovy groovyshell

我在Groovy shell中看不到任何从内存中删除变量的方法......这可能吗?我该怎么做呢?我可以在Beanshell和Javascript(Rhino)中看到这样做的方法,但在Groovy中却看不到.

tim*_*tes 8

我相信你能做到:

binding.variables.remove 'varname'
Run Code Online (Sandbox Code Playgroud)

或者,如果要删除所有变量,那么

purge variables
Run Code Online (Sandbox Code Playgroud)

也应该工作