Ask coding questions

← Back to all posts
Boolean and flag
Epraim (0)

Does anyone know how to write a boolean flag and can you break it down to me? please and thank you i am just 11 learning so thing can get hard.

Coder100 (10622)

I guess you can read this

DynamicSquid (4359)

I think you're referring to "booleans", or "bool" for short. Bools can only be of 2 types, true or false. They are used for when variables signify a on/off condition. They are also used in conditions and program flow.

bool isLightSwitchOn = true;
bool isSquidSmart = false;

Bools also get implicitly converted to 1s and 0s. That means behind the scenes, the compiler secretly changes all true values to 1, and all false values to 0. That's why if you print out true, you'll get 1. That also means that true and 1 are exactly the same, so are false and 0.

realTronsi (747)


bool did_you_understand_his_question = tralse;