mirror of
https://github.com/nushell/nushell.git
synced 2024-12-26 08:59:12 +01:00
8c0a2d3c15
* Finish updating * a couple improvements * Update renames * cleanup examples
639 B
639 B
title | layout | version |
---|---|---|
if | command | 0.59.0 |
Conditionally run a block.
Signature
> if (cond) (then_block) (else_expression)
Parameters
cond
: condition to checkthen_block
: block to run if check succeedselse_expression
: expression or block to run if check fails
Examples
Output a value if a condition matches, otherwise return nothing
> if 2 < 3 { 'yes!' }
Output a value if a condition matches, else return another value
> if 5 < 3 { 'yes!' } else { 'no!' }
Chain multiple if's together
> if 5 < 3 { 'yes!' } else if 4 < 5 { 'no!' } else { 'okay!' }