← Back to AILP Home

Conditionals Cookbook

This subsection is the canonical v0.40.x guide for Nitpick's conditional family: the if / else if / else statement chain and the is (cond) : a : b inline ternary. It supersedes the older, scattered conditional notes in guide/control_flow/ and the if/ternary fragments embedded in guide/basics/, where those pages are shorter or stale.

The v0.40.x cycle locked the shipped behavior of every conditional surface:

Chapters

  1. Basics — the conditional mental model, statement vs expression, and when to reach for if vs is vs pick.
  2. if / else if / else — the statement chain, block scope, and the order of arm evaluation.
  3. Conditions and bool — strict-bool conditions, why there is no truthiness, and raw fn() for Result<bool>.
  4. The is ternaryis (cond) : a : b, its type rules, and common patterns.
  5. Short-circuit — exactly-one-arm evaluation in is, and how it parallels if.
  6. Nested conditionals — nesting if and is, and how to keep chains readable.
  7. is vs pick vs when — choosing the right construct for a value, a multi-way branch, or a loop-completion hook.
  8. DiagnosticsARIA-IF-001/002/003 and ARIA-IS-001, what triggers them, and how to fix the underlying mistake.

Quick mental model

Validation snapshot (v0.40.x)