mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-07 14:27:24 +08:00
15 lines
296 B
Text
15 lines
296 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]
|
|
....
|
|
nix-repl> a = 7
|
|
|
|
nix-repl> b = 3
|
|
|
|
nix-repl> if a > b then "yes" else "no"
|
|
"yes"
|
|
....
|
|
|