Loading views...

Boolean

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2025 Nov 14 0:46
Editor
Edited
Edited
2025 Nov 14 0:58
Refs
Refs

Booleans feel like they make sense for our data or state, but they make sense for our logic

This means using it inside a function as a conditional variable
{ completed: boolean, failed: boolean, in_progress: boolean, }
easy to miss in if statement of the client code

Enum Data

{ status: 'failed' | 'completed' | 'in_progress' }
 

Check authorization

fn check_permissions(user: User) -> bool { false // no one is allowed to do anything i guess }
the application logic meaning of the value cannot be inferred from the type.
enum PermissionCheck { Allowed, NotPermitted(reason: String), }
 
 
 

Please Stop Using Booleans.

That boolean should probably be something else | nicole@web
One of the first types we learn about is the boolean. It's pretty natural to use, because boolean logic underpins much of modern computing. And yet, it's one of the types we should probably be using a lot less of. In almost every single instance when you use a boolean, it should be something else.
Please Stop Using Booleans.
Should we be using booleans? Yes, but a lot less then you think... Thank you Embrace for sponsoring! Check them out at: https://soydev.link/embrace SOURCE https://ntietz.com/blog/that-boolean-should-probably-be-something-else/ Want to sponsor a video? Learn more here: https://soydev.link/sponsor-me Check out my Twitch, Twitter, Discord more at https://t3.gg S/O Ph4se0n3 for the awesome edit 🙏
Please Stop Using Booleans.
 

Recommendations