Literals & quoting

Pairs

Full

A single key-to-value association — the building block of hashes and named args.

A Pair links one key to one value, written key => value. Pairs are the elements of a hash, the form of named arguments, and a value in their own right.

The fat-arrow form #

my $p = a => 1;
say $p;
say $p.key;
say $p.value;
Output
a => 1
a
1

Colon-pair forms #

:key(value) is the same Pair; :key alone means key => True, and :key<word> uses a quoted-word value. These are exactly the forms used for named arguments.

say (:x(5));
say (:done);
my $q = :name<Ada>;
say $q;
Output
x => 5
done => True
name => Ada

Notes #