3 ms·
This is completely off topic (though possibly still on the topic of maximal readability) but the correct way to express this logic is as follows: age >= 18
by gorgoiler 3y ago
This is completely off topic (though possibly still on the topic of maximal readability) but the correct way to express this logic is as follows:
age >= 18
If your code is specifically about the magical age of adulthood then it ought to include that age as a literal, somewhere.
It becomes more obvious when you consider replacing the inline literal with a named constant:
CHILD_UPTO = 17 # awkward
compared with:
ADULT = 18 # oh the clarity
My fellow turd polishers and I would probably also add a tiny type:
Age = int
ADULT: Age = 18 # mwah!
(The article was a good read, btw.)