323
True crime
(lemmy.nz)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
I mean aside of the variable name, this is not entirely unreasonable.
I would certainly rather see this than
{isAdmin: bool; isLoggedIn: bool}. Withboolean | null, at least illegal states are unrepresentable... even if the legal states are represented in an... interesting way.Admin false LoggedIn false doesn't feel illegal to me, more redundant if anything
I was thinking of the three legal states as:
nullor{isAdmin: false, isLoggedIn: false})falseor{isAdmin: false, isLoggedIn: true})trueor{isAdmin: true, isLoggedIn: true})which leaves
{isAdmin: true, isLoggedIn: false}as an invalid, nonsensical state. (How would you know the user's an admin if they're not logged in?) Of course, in a different context, all four states could potentially be distinctly meaningful.ah you are right! i am so dumb.
Honestly logged in is state and shouldn't be on the user object.