Skip Menu |
Report information
Id: 130947
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: smls75 [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



To: rakudobug [...] perl.org
Subject: [LTA] Multi-dimensional Hash subscripts return a List even when indexing a single element
From: "Sam S." <smls75 [...] gmail.com>
Date: Tue, 7 Mar 2017 16:09:27 +0100
Download (untitled) / with headers
text/plain 925b
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).


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org