3 ms·
True | False | FileNotFound was a meme about 2 decades ago, and even that was a reference to MSDOS from another 2 decades earlier. I guess things never change,
by ralferoo 7mo ago
True | False | FileNotFound was a meme about 2 decades ago, and even that was a reference to MSDOS from another 2 decades earlier. I guess things never change, only the language.
Even now, I still find myself using true/false/null on occasions, but I'm usually smart enough to replace it with an enum at that point. The only time I don't is when it's an optional parameter to a function to override some default/existing value, at which point it then makes sense to keep it as an optional bool.
- gizmo686 7mo agoI'm surprised that trinary logic has not become a standard part of standard libraries yet. Almost every project I have worked on ends up with some form of a yes/no/maybe abstraction.
- hinkley 7mo agoWith privacy coming back into vogue, it’s useful to distinguish “we didn’t ask” from “they wouldn’t answer” For some vector logic the distinction could matter.
- Aurornis 7mo agoYes/No/Maybe is a good fit for an enum because “Maybe” carries some specific information. For more common situations where the yes/no bool is not available yet or should not be considered, constructs like Rust’s Option<bool> are a very good fit. Layering the bool inside of an Option creates intentional handling about the presence or lack of value first before you can work with it.
- hinkley 7mo agoI did a govt contract early on and learned that yes/no/unanswered/unasked was a common quad. I see that in disclosures when applying for jobs as well.
- nine_k 7mo agoThis just means that the problem requires more than a Boolean, but rather something like boolean | error. In many languages from the OOP heyday that alternative part was expressed via throwing an exception.