3 ms·
If you find naming things difficult just append the type to the variable name, like strName, strCityName, nrAge, arrUserList, and try to make the types redundan
by z3t4 7y ago
If you find naming things difficult just append the type to the variable name, like strName, strCityName, nrAge, arrUserList, and try to make the types redundant. Then stop using the type annotations when you feel they are unnecessary: strName:string -> strName -> name
This of course only works in high level dynamic languages where you wont have 25 ways to represent a number, or 32 ways to make a string (different encodings). In a typed systems level language the compiler should be able to optimize and figure out the best type to use though.
- golergka 7y agoBut why would you use the type "string" in the first place, instead of declaring a type "name"?