Arrays: Difference between revisions
m
Perl6 -> Raku
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
Thundergnat (talk | contribs) m (Perl6 -> Raku) |
||
Line 5,502:
=={{header|Raku}}==
(formerly Perl 6)
At its most basic, an array in
<lang perl6>my @arr;
Line 5,515:
===Some further exposition:===
In
Arrays are unconstrained by default. They may hold any number of any type of object up to available memory. They do not need to be pre-allocated. Simply assigning (or even referring in some cases) to an index slot is enough to autovivify the container and allocate enough memory to hold the assigned object. Memory will automatically be allocated and will grow and shrink as necessary to hold the values assigned.
Line 5,537:
my @implicit = <yep, this too>
Array variables in
@array[1] # a single value in the 2nd slot
@array[*-1] # a single value in the last slot
Line 5,553:
@array[1;1] # same thing, implies rectangular (non-ragged) arrays
There are several objects that have an Iterable Role and a PositionalBindFailover Role which makes them act similar to arrays and allows them to be used nearly interchangeably in read-only applications. (
'''List''': A fixed Iterable collection of immutable values. Lists are constructed similarly to arrays:
|