10BC0 Return assigned value while using pipeline `let` · Issue #17421 · nushell/nushell · GitHub
[go: up one dir, main page]

Skip to content

Return assigned value while using pipeline let #17421

@pixlxip

Description

@pixlxip

Basics

  • I have done a basic search through the issue tracker to find similar or related issues.
  • I have made myself familiar with the available features of Nushell for the particular area this enhancement request touches.

Related problem

I'd like to be able to assign the current value of a pipeline to be set to a variable while continuing the pipeline with the same data. I am not sure how this would work with streaming.

Describe the solution you'd like

This would allow for previous values to be used later:

$products
| get price
| math sum
| let subtotal
| apply_taxes
| { subtotal: $subtotal, total: $in }

Describe alternatives you've considered

You could just end the pipeline and start a new one with the value that was just assigned (... | let subtotal; $subtotal | ...) but this seems unnecessary and may prevent streaming.

Additional context and details

This probably wouldn't break any existing code because:

  • Pipeline let a new feature.
  • Functions generally don't end with a let statement while assuming to return null.
  • I don't think people would put a pipe after a pipeline let while expecting to get a null value from the assignment. It would make much more sense to start a new pipeline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0