4 ms·
I still think the difference to me as a programmer is largely semantic (except when the performance has to be considered): "rebinding" or "in-place mutation", i
by cies 2y ago
I still think the difference to me as a programmer is largely semantic (except when the performance has to be considered): "rebinding" or "in-place mutation", in both cases it is a mutable variable to me.
- borromakot 2y agoThere is a guarantee that you have when rebinding is the only option. with rebinding: def thing() do x = 10 do_something(x) # x is 10, non negotiably, it is never not 10 end with mutability def thing() do x = 10 do_something(x) # who knows what x is? Could be anything. end Additionally, because rebinding is a syntactic construct, you can use a linter to detect it: https://hexdocs.pm/credo/Credo.Check.Refactor.VariableRebinding.html https://hexdocs.pm/credo/Credo.Check.Refactor.VariableRebind...
- cies 2y agoI find this a much better example than the example shown in the article. I even find it quite useful when explained like this. Thanks!