开发者

How do you unbind variables in an interactive Erlang session?

开发者 https://www.devze.com 2022-12-24 05:37 出处:网络
In the Erlang interactive shell you can bind variables to values. If I would l开发者_如何学Goike to clear everything and start from scratch without exiting the session and starting a new one, how do I

In the Erlang interactive shell you can bind variables to values. If I would l开发者_如何学Goike to clear everything and start from scratch without exiting the session and starting a new one, how do I do that?

And if I just wanted to re-use a single variable, is it possible to re-bind?


Use f() and f(Var):

1> A = 1, B = 2.
2
2> f(A).
ok
3> A.
* 1: variable 'A' is unbound
4> B.
2
5> f().
ok
6> B.
* 1: variable 'B' is unbound
7>

Shell commands are actually functions in the 'c' module: http://www.erlang.org/doc/man/c.html


And if I just wanted to re-use a single variable, is it possible to re-bind?

Yes, when you "unbind" (f(Val) - forget) the value you can re-bind (match) it again. Needless to say it only works in erlang shell.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号