Documentation for trait is copy
Documentation for trait is copy, assembled from the following types:
By default, parameters are bound to their argument and marked as read-only. One can change that with traits on the parameter.
is copy trait causes the argument to be copied, and allows it to be modified inside the routine
sub count-up( is copy)
is rw trait makes the parameter bind to a variable (or other writable container). Assigning to the parameter changes the value of the variable at the caller side.
sub swap( is rw, is rw)
On slurpy parameters,
is rw is reserved for future use by language designers.
is raw trait is automatically applied to parameters declared with a backslash as a "sigil", and may also be used to make normally sigiled parameters behave like these do. In the special case of slurpies, which normally produce an
Array full of
Scalars as described above,
is raw will instead cause the parameter to produce a
List. Each element of that list will be bound directly as raw parameter.
To explicitly ask for a read-only parameter use the
is readonly trait. Please note that this applies only to the container. The object inside can very well have mutator methods and Perl 6 will not enforce immutability on the attributes of the object.
Traits can be followed by the where clause:
sub ip-expand-ipv6( is copy where m:i/^**3..39$/)