Skip to content

Spread Operator not properly spread in example #2003

@AlOwain

Description

@AlOwain

This is an issue, and not a pull request because I am new to Nushell and would like to confirm that this is in fact not proper behavior.

In Programming In Nu#Operators:262 (shown below)

foo "bar" "baz" ...[1 2 3]
# => [false, bar, baz, [1, 2, 3]]
foo "bar" "baz" [1 2 3]
# => [false, bar, baz, [[1, 2, 3]]]

The example (and many others in the same file) seem to indicate in the comments, that the default behavior of appending a list to another is that it is encapsulated as another list, and spreading it only appends the list as-is. My assumption would be that it wouldn't, and trying it out in the Shell seems to indicate so, for example:

~> ["bar" "baz" ...[1 2 3]] | to nuon
[bar, baz, 1, 2, 3]
~> ["bar" "baz" [1 2 3]] | to nuon
[bar, baz, [1, 2, 3]]

The absence of foo is intentional, as it does not change the demonstrability of the issue.

As a precursor, I had attempted to check for issues, or pull requests that mention this, it does not seem to have been addressed. The git blame result is a commit in the pull request #1692, which has many changes indicating that it could have just slipped by.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions