Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] perlref postfix dereference can be used on LHS #22130

Open
epa opened this issue Apr 9, 2024 · 0 comments
Open

[doc] perlref postfix dereference can be used on LHS #22130

epa opened this issue Apr 9, 2024 · 0 comments

Comments

@epa
Copy link
Contributor

epa commented Apr 9, 2024

Where
perlref section Postfix Dereference Syntax

Description
The documentation is accurate to say that postfix deref works in all cases where block deref does. But it doesn't specially mention that this includes on the LHS of an assignment. It could do with a mention of
$aref->@* = (1, 2, 3); # same as @{ $aref } = (1, 2, 3)
just to reassure the reader.

(what follows is more of an opinion and might or might not be suitable for incusion in perlref) Perhaps a common usage of postfix on the LHS would be for
$aref->@* = foo();
This is, of course, not equivalent to
$aref = [ foo() ];
but it can be a good enough replacement in many cases, when you know $aref was undefined before, and is visually easier to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants