On Mon, Aug 6, 2018 at 4:40 PM ToddAndMargo <toddandma...@zoho.com> wrote:

> Is there a way to force all the members of an array
> to be integers and to error out is a non-integer
> is written to one of its cells?
>

Sure, from the examples in the docs:
https://docs.perl6.org/language/list#Typing

my Int @a = 1, 2, 3;              # An Array that contains only Ints
my @b := Array[Int].new(1, 2, 3); # Same thing, but the variable is not typed
my @b := Array[Int](1, 2, 3);     # Rakudo shortcut for the same code

@a[0] = 42;                       # fine
@a[0] = "foo";                    # error: Type check failed in assignment

Reply via email to