3 ms·
The issue isn’t booleans the issue is that the code doesn’t handle all the states described by the two booleans, when all are possible.
by liontwist 2y ago
The issue isn’t booleans the issue is that the code doesn’t handle all the states described by the two booleans, when all are possible.
- cma 2y agoMake the impossible states unrepresentable using an enum of only the possible boolean combinations.
- dpig_ 2y agoIsn't that exactly what the article prescribes?
- liontwist 2y agoDid you read the context?
- cma 2y agoNo I read wrong and missed it. If all four states are actually possible an enum can still be a win if you have a compiler that can check for exhaustive switch case statements. Or especially if updating a system where it used to be only three were valid and now something changed so that all four are.