typeover
curriculum

Curriculum Basics Conditionals (if and switch) exercise 5 · fill-word

Conditionals (if and switch)

Fill the missing keyword. The line evaluates a value against multiple patterns and returns a string. In Zig this construct is an expression, not a statement.

TypeScript reference
Fill the blanks →

About this theme

Zig's if looks like TypeScript's: parens around the condition, optional braces around the body. The catch: Zig has no truthy values — the condition must be bool. switch is an expression in Zig (not a statement), so it can be assigned directly. The TS reflex matches Zig here more cleanly than it matches Go.