The only flaw is that the console.log states that null means user is not logged in.
If there are three or more explicit states, you should not use a nullable bool, but some more explicit data structure, like enum.
For example, if the state comes from a db, the user could be successfully logged in, but somehow for a range of possible reasons this variable ends up as null and you’ll have a hell of a time debugging, because the log will give you nonsense.
The only flaw is that the console.log states that null means user is not logged in.
If there are three or more explicit states, you should not use a nullable bool, but some more explicit data structure, like enum.
For example, if the state comes from a db, the user could be successfully logged in, but somehow for a range of possible reasons this variable ends up as null and you’ll have a hell of a time debugging, because the log will give you nonsense.
Good point.