On 2020-01-20 20:36, 浪花城主 wrote:
How about returning a reference?
Just for test (sorry I have no perl6 installed on local device):
$ perl -le 'sub x {%hash=(1,2,3,4);\%hash}; print x->{1}'
2
Regards.
Hi 浪花城主,
No Perl6 installed???? I am Heart Broken!!! Why!
Why! KIDS THESE DAYS!!
:-)
I do not understand what you mean by "reference"?
Do you mean the key(s)?
> say x.keys
(A)
> sub x() returns Hash { my %h= A=>"a", B=>"b"; return %h}
&x
> say x.keys
(B A)
> say x<B>
b
Be aware that they are not stored in the order you
place them. I have no clue why.
In Perl 5, we have a think called "reference".
It is a structure that points to another structure.
Basically, it a C Pointer on steroids. Perl 6 has
no such animal as it does not need one (YIPPEE!!).
-T