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

array of strings!

From:
ToddAndMargo via perl6-users
Date:
July 5, 2021 09:13
Subject:
array of strings!
Message ID:
a416c1a3-9e25-6f83-0265-0ad891ab3a48@zoho.com
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 <unit> at <unknown file> line 1


:-)

-T



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