0Pricing
Zig Academy · Lesson

bool, void, and the Comptime Types

The small but essential primitives.

bool, void, and the Comptime Types is a free Zig Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Zig Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Small but Essential Types

Beyond numbers, Zig has a handful of tiny primitives that show up everywhere: bool, void, and special compile-time number types. 🧩

bool Holds True or False

A bool stores exactly one of two values: true or false. It drives every if statement and while condition you write.

const ready: bool = true;

Booleans Come from Comparisons

Comparison operators produce booleans. The expression 5 > 3 evaluates to true, which you can store or test directly.

const bigger = 5 > 3; // true

void Means No Value

The void type represents the absence of a value. A function returning void hands back nothing meaningful when it finishes.

fn log() void {
    // does work, returns nothing
}

Where void Shows Up

You see void as the return type of side-effect functions, and as the payload of containers that only care that a key exists.

comptime_int for Whole Literals

An untyped whole number like 42 starts as a comptime_int. It has arbitrary precision and only gains a fixed width when assigned.

const n = 42; // comptime_int until used

comptime_float for Decimals

Similarly, an untyped decimal such as 3.14 is a comptime_float. It is exact at compile time before it becomes an f32 or f64.

const ratio = 3.14; // comptime_float

Comptime Numbers Are Flexible

Because they are compile-time only, these types can hold huge or tiny values precisely. They coerce into sized types when you use them.

The type Type

In Zig a type is itself a value with the type named type. This is what lets functions accept and return types for generics.

const T: type = i32;

anyopaque for Unknown Data

The anyopaque type marks memory whose shape is unknown, often used at C boundaries where the layout is hidden from Zig.

Why These Primitives Matter

Together these small types give Zig its foundation: booleans for logic, void for nothing, and comptime numbers for flexible literals.

Quick Check

You write the literal 100 with no type annotation. Before it is assigned anywhere, what type does Zig give it?

Recap

Remember the small primitives: bool for true or false, void for no value, and comptime_int and comptime_float for flexible literals. 🎯

Frequently asked questions

Is the “bool, void, and the Comptime Types” lesson free?

Yes — the full text of “bool, void, and the Comptime Types” is free to read here on the web, and the Zig Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Zig Academy course, upgrade to CoddyKit PRO.

What will I learn in “bool, void, and the Comptime Types”?

The small but essential primitives. You practise Zig Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Zig Academy?

No prior experience is required. Zig Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “bool, void, and the Comptime Types” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Zig Academy lesson?

Yes. Every Zig Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Sized Integers: i32, u8, usize
  2. Floating Point: f32 and f64
  3. bool, void, and the Comptime Types
  4. Number Literals and Underscores
← Back to Zig Academy