Re: how do I assign an array to a hash key

2017-09-28 Thread ToddAndMargo

On 09/28/2017 09:47 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 12:44 AM, ToddAndMargo > wrote:


I will probably use the @ for a while until I get use to
it for readability.


I think that's actually disrecommended, because it looks too much like 
Perl 5's refs but isn't, so it can bite you unexpectedly if you treat it 
like one.


okay, but I don't know how to di it in Perl 5, so ...

P6's sub declarations are so much better than P5's it take
my breath away.


Re: how do I assign an array to a hash key

2017-09-28 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 12:44 AM, ToddAndMargo 
wrote:

> I will probably use the @ for a while until I get use to
> it for readability.
>

I think that's actually disrecommended, because it looks too much like Perl
5's refs but isn't, so it can bite you unexpectedly if you treat it like
one.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: how do I assign an array to a hash key

2017-09-28 Thread ToddAndMargo

On 09/28/2017 09:43 PM, Brandon Allbery wrote:
On Fri, Sep 29, 2017 at 12:32 AM, ToddAndMargo > wrote:


$ perl6 -e 'my %x = [aaa => "x", b=>@["y","q","r"], c=>"z"]; say %x;
for @(%x) {say $_};'
{aaa => x, b => [y q r], c => z}
y
q
r

This seems too easy.  I have to have done something wrong.
What did I miss?


Only that it's even easier than you think: the @ was unnecessary when 
building it. Perl 6 handles this kind of thing much better than Perl 5. 
And there are other ways to spell the destructuring as well.


     pyanfar Z$ 6 'my %x = [aaa => "x", b=>["y","q","r"], c=>"z"]; say 
%x; for %x[*] {say $_};'

     {aaa => x, b => [y q r], c => z}
     y
     q
     r


Thank you!


I will probably use the @ for a while until I get use to
it for readability.


Re: how do I assign an array to a hash key

2017-09-28 Thread Brandon Allbery
On Fri, Sep 29, 2017 at 12:32 AM, ToddAndMargo 
wrote:

> $ perl6 -e 'my %x = [aaa => "x", b=>@["y","q","r"], c=>"z"]; say %x; for
> @(%x) {say $_};'
> {aaa => x, b => [y q r], c => z}
> y
> q
> r
>
> This seems too easy.  I have to have done something wrong.
> What did I miss?
>

Only that it's even easier than you think: the @ was unnecessary when
building it. Perl 6 handles this kind of thing much better than Perl 5. And
there are other ways to spell the destructuring as well.

pyanfar Z$ 6 'my %x = [aaa => "x", b=>["y","q","r"], c=>"z"]; say %x;
for %x[*] {say $_};'
{aaa => x, b => [y q r], c => z}
y
q
r


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: how do I assign an array to a hash key

2017-09-28 Thread ToddAndMargo

On 09/28/2017 09:32 PM, ToddAndMargo wrote:

Hi All,

I am creating a hash.  One of the keys I want to point to an array,
not a string.

I have created a test:

$ perl6 -e 'my %x = [aaa => "x", b=>@["y","q","r"], c=>"z"]; say %x; for 
@(%x) {say $_};'

{aaa => x, b => [y q r], c => z}
y
q
r

This seems too easy.  I have to have done something wrong.
What did I miss?

-T



Way to easy.

$ perl6 -e 'my %x = [aaa => "x", b=>@["y","q","r"], c=>"z"]; push 
@(%x), ""; say %x; for @(%x) {say $_};'

{aaa => x, b => [y q r ], c => z}
y
q
r



I am very suspicious.


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~