Force integers in an array?

Hi All,

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?


Many thanks,
-T
0
ToddAndMargo
8/6/2018 8:38:57 PM
perl.perl6.users 1110 articles. 0 followers. Follow

2 Replies
44 Views

Similar Articles

[PageSpeed] 23

> my Int @a;
> @a[0] = '1'
Type check failed in assignment to @a; expected Int but got Str ("1")
  in block <unit> at <unknown file> line 1
On Mon, Aug 6, 2018 at 3:39 PM ToddAndMargo <ToddAndMargo@zoho.com> wrote:
>
> Hi All,
>
> 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?
>
>
> Many thanks,
> -T
0
b2gills
8/6/2018 8:42:38 PM
On 08/06/2018 01:42 PM, Brad Gilbert wrote:
>> my Int @a;
>> @a[0] = '1'
> Type check failed in assignment to @a; expected Int but got Str ("1")
>    in block <unit> at <unknown file> line 1
> On Mon, Aug 6, 2018 at 3:39 PM ToddAndMargo <ToddAndMargo@zoho.com> wrote:
>>
>> Hi All,
>>
>> 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?
>>
>>
>> Many thanks,
>> -T

Thank you!
0
ToddAndMargo
8/6/2018 9:00:07 PM
Reply: