Operators
The slip operator |
FullFlatten a list into the surrounding list, in place.
Prefix | turns a list into a Slip — a list that dissolves into its container. Where a nested list would stay nested, a slipped one merges its elements into the enclosing list.
Flattening in place #
my @a = 1, |(2, 3), 4; say @a; say (1, |(2, 3), 4).elems;
Output
[1 2 3 4]
4Without the |, (2, 3) would be one nested element; slipped, its 2 and 3 sit directly in the list, so the total length is 4.
Notes #
|is also how you pass a list as separate arguments to a call:f(|@args)spreads@argsintof's parameters (the reverse of a slurpy*@).- A
Slipis a real value (slip(2, 3)or theSliptype) — returning one from amapblock lets a single element expand into several results. - It's the list-level analogue of the
|in signatures/captures, and distinct from the numeric/junction|(ananyjunction on numbers).