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
606 B
606 B
title | layout | version |
---|---|---|
for | command | 0.59.0 |
Loop over a range
Signature
> for (var_name) (range) (block) --numbered
Parameters
var_name
: name of the looping variablerange
: range of the loopblock
: the block to run--numbered
: returned a numbered item ($it.index and $it.item)
Examples
Echo the square of each integer
> for x in [1 2 3] { $x * $x }
Work with elements of a range
> for $x in 1..3 { $x }
Number each item and echo a message
> for $it in ['bob' 'fred'] --numbered { $"($it.index) is ($it.item)" }