nix-book/source/nix-language/if.adoc
Amy de Buitléir 96f65dd5a5 expanded
2025-10-12 15:59:19 +01:00

16 lines
305 B
Text

= If expressions
The conditional construct in Nix is an _expression_, not a _statement_.
Since expressions must have values in all cases, you must specify both the `then` and the `else` branch.
[source]
.Example
....
nix-repl> a = 7
nix-repl> b = 3
nix-repl> if a > b then "yes" else "no"
"yes"
....