0Pricing
Zig Academy · Lesson

Boolean Logic and Short-Circuiting

Combine conditions with and, or, not.

Thinking in True and False

A bool holds just two values: true or false. Boolean logic lets you combine these answers to make richer decisions in your code.

The and Operator

Zig spells logical and with the keyword and. The whole expression is true only when both sides are true; otherwise it is false.

const ok = isReady and hasFuel;

All lessons in this course

  1. Arithmetic and Comparison Operators
  2. Overflow: + vs +% vs +|
  3. Bitwise Operators
  4. Boolean Logic and Short-Circuiting
← Back to Zig Academy