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

2021-07-05 Thread Norman Gaywood
$ raku Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.06. Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d. Built on MoarVM version 2021.06. To exit type 'exit' or '^D' > class AA { has Str @.I is rw; }; (AA) > my $CC = AA.new( I => [Str,"abc"] ); AA.new(I => Array[Str].new(Str, "abc")) > say $CC.I; [(Str) abc] > say $

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

2021-07-05 Thread ToddAndMargo via perl6-users
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 r

array of strings!

2021-07-05 Thread ToddAndMargo via perl6-users
Hi All, I am sure yo guys already knew this, but I discovered something new. I can constrain an array to a type. Array of strings: > my Str @x; [] > @x[1] ="abc"; abc > @x[0] = 12.3; Type check failed in assignment to @x; expected Str but got Rat (12.3) in block at line 1 :-) -T