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] perldata hash slice example will blow up if used for more than depth 1 #17721

Open
jidanni opened this issue Apr 16, 2020 · 0 comments
Open

Comments

@jidanni
Copy link
Member

jidanni commented Apr 16, 2020

perldata says

Since you can assign to a list of variables, you can also assign to an array or hash slice ...

@colors{'red','blue','green'} = (0xff0000, 0x0000ff, 0x00ff00);

The previous assignments are exactly equivalent to ...

($colors{'red'}, $colors{'blue'}, $colors{'green'}) = (0xff0000, 0x0000ff, 0x00ff00);

OK, but it needs to mention more than just one depth,

@{$colors{favorites}}{ 'red', 'blue', 'green' } #OK

Else users will extend the analogy presented, and assume

@colors{favorites}{ 'red', 'blue', 'green' } #syntax error

will work !

Also mention there is no way to use a consistent syntax for first vs.
more layers.

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

1 participant