3 ms·
My understanding is that you can't set the variable per se. Rather, you can only bind a new variable with the same name, shadowing the old binding. This is very
by tikhonj 14y ago
My understanding is that you can't set the variable per se. Rather, you can only bind a new variable with the same name, shadowing the old binding. This is very similar to how let bindings work in other languages like OCaml and Scheme.
So changing a is more akin to creating a new scope with a new value bound to a rather than mutating a. However, I should be clear that I'm just inferring this from how let statements work in other languages--I've never actually used Elixir.
- josevalim 14y agoThis is correct. That's how Elixir works.