DEV Community

Discussion on: Optional booleans?

 
daniel13rady profile image
Daniel Brady

I think that makes sense, though, right? If it's required, a default isn't necessary or applicable. If it's optional, you need a sane default.

But I didn't say anything about not having optional booleans: quite the contrary, I was talking about the case where you do have optional booleans, and paraphrasing Ben's comment about it.

Thread Thread
 
moopet profile image
Ben Sinclair

@dabrady yeah, that's what I meant. If there's a useful semantic difference between three states then it should be an enum or something, but if the third state is just there beacuse it's unfilled, why not fill it?

Thread Thread
 
lexlohr profile image
Alex Lohr

Because it might only be for one of the use cases of your API. Should the developer using it need to care about all the use cases that don't matter to him? I should think that is a waste of his time.