Lesson contents

Comparisons

Compare two numbers to answer a yes-or-no question. Equality counts when you use a greater-than-or-equal check.

Simple example

Is three at least two?

Start3 ≥ 2
Resulttrue
lesson.zig
const std = @import("std");

pub fn main() !void {
    std.debug.print("{any}\n", .{3 >= 2});
}
Output
true
Advertisements

Everyday examples

A lift has space for four riders. Can all four people waiting board together?

Start4 spaces · 4 people
Resulttrue
lesson.zig
const std = @import("std");

pub fn main() !void {
    std.debug.print("{any}\n", .{4 >= 4});
}
Output
true
Run the example
Terminal
zig run lesson.zig
Official documentation