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

Multi-dimensional Hash subscripts return a List even when indexing a single element #6130

Open
p6rt opened this issue Mar 7, 2017 · 2 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 7, 2017

Migrated from rt.perl.org#130947 (status was 'new')

Searchable as RT130947$

@p6rt
Copy link
Author

p6rt commented Mar 7, 2017

From @smls

When using a multi-dimensional Hash subscript of the form `.{ ; }` the
result is always returned as a List (as if taking a slice), even if
the subscript for each dimension is scalar​:

  my %hash = a => {b => 2, c => 4};

  say %hash{"a"}{"b"}.perl; # 2
  say %hash{"a";"b"}.perl; # (2,)

That doesn't seem logical, and is also inconsistent with multi-dimensional
*Array* subscripts​:

  my @​array = 0, [0, 0, 42];
  say @​array[1][2].perl; # 42
  say @​array[1;2].perl; # 42

On the other hand, the design docs don't have much to offer on the subject...

- https://design.perl6.org/S09.html#Hashes -- Shows how to *statically
declare* multi-dimensional Hashes (NYI in Rakudo), but not how to
index them.

- https://design.perl6.org/S09.html#User-defined_array_indexing --
Shows mutli-dimensional associative indexing, but not for Hashes but
rather for *Arrays with user-defined indices* (NYI in Rakudo).

@p6rt
Copy link
Author

p6rt commented Aug 28, 2017

From @smls

I sent a pull request which fixes this bug​:

rakudo/rakudo#1139

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant