loop

For core.

Run a block in a loop.

Command Type

keyword

Signature

> loop {flags} (block)

Parameters

  • block: Block to loop.

Input/output types:

input output
nothing nothing

Examples

Loop while a condition is true.

> mut x = 0; loop { if $x > 10 { break }; $x = $x + 1 }; $x
11

Notes

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

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.