Skip to main content

Flag

A Flag value is an efficient way of storing whether particular flags are on and off. It is represented as a 32-bit integer, where each bit represents a flag. To specify a Flag literal, use the 0b prefix followed by a binary number, or 0x followed by a hexadecimal number.

// The 0b prefix creates flags from a binary number
0b100 // flag 3 is on
0b100 | 0b010 // bitwise OR - output is 0b110

// The 0x prefix creates flags from a hexadecimal number
0x4 // equivalent to 0b100