Spec-Zone.ru › Nushell

if for core

Conditionally run a block.

Signature

> if {flags} (cond) (then_block) (else_expression)

Parameters

  • cond: Condition to check.
  • then_block: Block to run if check succeeds.
  • else_expression: Expression or block to run when the condition is false.

Input/output types:

input output
any any

Examples

Output a value if a condition matches, otherwise return nothing.

> if 2 < 3 { 'yes!' }
yes!

Output a value if a condition matches, else return another value.

> if 5 < 3 { 'yes!' } else { 'no!' }
no!

Chain multiple if's together.

> if 5 < 3 { 'yes!' } else if 4 < 5 { 'no!' } else { 'okay!' }
no!

Notes

This command is a parser keyword. For details, check: https://www.nushell.sh/book/thinking_in_nu.html

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/if.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API