3 ms·
I feel like a common refactor in a large project might be a complete redefinition of a model layer exposed via a bunch of structs. How does immutability or pat
by turdprincess 3y ago
I feel like a common refactor in a large project might be a complete redefinition of a model layer exposed via a bunch of structs.
How does immutability or patter matching save me from runtime errors caused by changing the fields or types inside a struct? Wouldn’t the pattern matching just fail and go down the wrong code path since it was matching for the old pattern?
I feel like immutability is great, pattern matching is great, but static typing is also great and there is no reason why it can’t happily live along side the other two.
- AlchemistCamp 3y agoIn this case, the question is moot. Elixir structs have compile-time checks: https://elixir-lang.org/getting-started/structs.html https://elixir-lang.org/getting-started/structs.html