Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 24 lines (14 sloc) 0.43 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#! nqp

# check positional subscripting

plan(7);

my @l := (1,2,3,4,5);

say("ok 1 # list assignment didn't barf");
say('ok ',@l[1], ' # numeric subscript');
say('ok ', @l['2'], ' # string subscript');

my $idx := 3;

say('ok ', @l[$idx], ' # variable subscript');
say('ok ', @l[$idx + 1], ' # expression in subscript');

@l[0] := 'ok 6 # string array element';
say(@l[0]);

@l[10] := 'ok 7 # automatic expansion';
say(@l[10]);

Something went wrong with that request. Please try again.