How to remove allocated value of a specific variable in Erlang?

Can anyone tell me that if I bound the variable with incorrect value then how can I replace with another value.
for example: I have create a variable in Erlang shell:
> One = 2.          // by mistake bound wrong value in variable One.
> One = 1.          // if we again bound with new value then it generates error.
"exception error: no match of right hand side value 1"

So please tell me how to unbound any specific variable.
Last updated:3/9/2016 11:19:18 PM

1 Answers

Tarun Kumar
Tarun Kumar

The Variable which is already bounded then you can't bound it again. In Erlang operator (=) is used for pattern match not for initialization. But If the Variable is unbound and we use operator (=) then data on the right-hand side will be bound on the left-hand side Variable.
If you want to bound another data then you need to unbound that Variable first.
In Erlang Shell you can use f() function to unbound all the Variables. and to unbound any particular Variable use f(Variable_Name).
For Example:
> One = 2.
> f(One).
> One = 1.
Now, Variable One is bounded with value 1.
That's it.