Skip to content

Arrayref and hashref destructuring in subroutine signatures and assignment #55

@akarelas

Description

@akarelas

It would be nice if we could do:

sub foo ([$x, $y]) {
    say "$x, $y";
}

...instead of:

sub foo ($pair) {
    my ($x, $y) = @$pair;
    say "$x, $y";
}

...but also (if the previous has been done):

my { $x, $y } = { x => 5, y => 6 };

...or:

my { x => $value_x, y => $value_y } = { x => 5, y => 6 };

Would certainly help with users of RxPerl, who often write code like:

$observable->pipe(
    op_pairwise,
    op_map(sub ($pair) {
        my ($old, $new) = @$pair;
        ...
    }),
);

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