filmov
tv
The Bool Mistake EVERY Beginner Developer Makes #codingtips #gamedevelopment #devlog

Показать описание
Are you making this simple coding mistake? There's a clean, easy way to check if a bool is true or false.
In this video I use a personal example from an 8 year old codebase of mine to demonstrate the simple yet effective way to compare bool values. Beginners tend to compare the stored variable against the value of true or false to check the state.
Instead, we can simply use an if condition directly using the bool variable to check if it's true if(boolVariable). If we want to check if it's false, we can simply use an exclaimation point infront of our varibale like so if(!boolVariable).
However, as explained in this video, there are certianly use cases for comparing against the value of true/false, for instance when the bool variable has a chance to be null.
#programmingtips #cleancode #gamedevlog #gamedevelopment #devlog #unity #csharp
In this video I use a personal example from an 8 year old codebase of mine to demonstrate the simple yet effective way to compare bool values. Beginners tend to compare the stored variable against the value of true or false to check the state.
Instead, we can simply use an if condition directly using the bool variable to check if it's true if(boolVariable). If we want to check if it's false, we can simply use an exclaimation point infront of our varibale like so if(!boolVariable).
However, as explained in this video, there are certianly use cases for comparing against the value of true/false, for instance when the bool variable has a chance to be null.
#programmingtips #cleancode #gamedevlog #gamedevelopment #devlog #unity #csharp