develooper Front page | perl.perl6.users | Postings from July 2021

How do a pe-salt an array inside an object?

Thread Next
From:
ToddAndMargo via perl6-users
Date:
July 6, 2021 00:55
Subject:
How do a pe-salt an array inside an object?
Message ID:
7ae9409f-84e6-966d-65ff-0c8d82ce2ce7@zoho.com
Hi All,

On creation, I would like to salt some of the
values inside an object  when the variable
inside is an array:


First a concept test:
$ p6 'class AA { has Str @.I is rw; }; my $CC= AA.new; $CC.I[1] = "def"; 
say $CC.I[1];'

def


Now for the pre-salt test
$ p6 'class AA { has Str @.I is rw; }; my $CC = AA.new( I[1] => "abc" ); 
say $CC.I[1];'

===SORRY!=== Error while compiling -e
Undeclared name:
     I used at line 1


What am I doing wrong?

Many thanks,
-T

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I had a dime every time I didn't know
what was going on, I'd be like, "Why is
everyone giving me all these dimes?"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About