3 ms·
Yep. I used to not do this, but now, self documentation and clear understanding of how that variable should be used is awesome. In Rust I've even started doing
by bluejekyll 10y ago
Yep. I used to not do this, but now, self documentation and clear understanding of how that variable should be used is awesome.
In Rust I've even started doing something additional which is use the shadowing feature. This was always a big no-no in other languages, some don't allow it, others do something different, but in Rust it can be used safely to reduce the explosion of variables in certain contexts. This helps reduce the need for distinctions between variables, allowing for shorter names.
- MichaelGG 10y agoRebinding variables (let age = "123"; let age = int(age)) is excellent and it's a shame more languages don't let you use it. It lets you keep immutability while making sure an old value isn't used.