Skip to content

Arrays in Perl 6

James E Keenan edited this page Feb 6, 2016 · 7 revisions

Basic questions about arrays.

You can define arrays of fixed length, then assign to individual elements.

#!/usr/bin/env perl6

my @array[10];
@array[0] = 7;
@array[3] = 'string';
say @array;

Output:

$ perl6 array.pl6 
[7 (Any) (Any) string (Any) (Any) (Any) (Any) (Any) (Any)]

Radix notation: for expressing integers in bases other than base 10:

my $ox = :8<63>;
my $hx = :16<a1>;

say $ox;
say $hx;

Output:

51
161
Clone this wiki locally