Skip to content

Independent splats in array pattern matching #870

@TrevorBurnham

Description

@TrevorBurnham

Let's say that I want to get the first and last values of an array of arbitrary length, in a nice one-line statement. I could write

[first, middle..., last] = arr

But this is less than ideal from both a code efficiency standpoint and a readability standpoint, since I never use middle. What I'd prefer to write is simply

[first, ..., last] = arr

Do others agree that this should be allowed?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions