collect for filters

Collect the stream and pass it to a block.

Signature

> collect {flags} (closure)

Flags

  • --keep-env, -: let the block affect environment variables

Parameters

  • closure: The closure to run once the stream is collected.

Input/output types:

inputoutput
anyany

Examples

Use the second value in the stream

> [1 2 3] | collect { |x| $x.1 }
2