perl6/doc/lib/Parcel

doc src
(title) class Parcel
    class Parcel is Cool does Positional { }

 
I<Parcel> stands for I<Par>enthesis I<cel>l, ie an expression surrounded by parenthesis. Though with the exception of the empty parcel, () , it is really the comma that creates a Parcel.
    (1 + 2) # not a Parcel
    ()      # empty Parcel
    (1,)    # Parcel with one element
    (1, 2)  # Parcel with two elements

 
Parcels are immutable, but can contain mutable containers.
    my $x;
    my $p = (0, $x, 2); # can assign to $p[1], but not
                        # to any other element of $p

 
Word-quoting constructs such as < <... >> also create parcels:
    <a b c> # 3-element Parcel

 
In flattening list context, parcels are flattened out and disappear:
    my @flat = <a b>, <c, d>;
    say @flat.elems;            # 4

 

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: