3 ms·
Have you never heard the rule that your code should have no numbers in it except 0 and 1? All other numbers should be written as constants instead, and then use
by ars 11y ago
Have you never heard the rule that your code should have no numbers in it except 0 and 1? All other numbers should be written as constants instead, and then use the name of the constant instead of the number directly.
> Anointing "+ 1" as a thing that needs special syntax is weird.
1 is special.
- cballard 11y agoYes, of course, I use constants in all cases. Why is adding 1 to something special, compared to adding 2 to something? The #1 use case, by far, is C-style for loops, which aren't used in idiomatic Swift code.
- ars 11y agoI said why: The 2 should be a constant as a name, but the 1 can be a bare 1.