control flow gather take
Documentation for control flow gather take, assembled from the following types:
From Control Flow
my = gathersay join ', ', ; # OUTPUT: «1, 5, 42␤»
gather/take can generate values lazily, depending on context. If you want to force lazy evaluation use the lazy subroutine or method. Binding to a scalar or sigilless container will also force laziness.
my = lazy gathersay ;say 'between consumption of two values';say ;# OUTPUT:# 1# between consumption of two values# Produced a value# 2
gather/take is scoped dynamically, so you can call
take from subs or methods that are called from within
sub weird(, : = 'forward')say weird(<a b c>, :direction<backward> ); # OUTPUT: «(c b a)␤»
If values need to be mutable on the caller side, use take-rw.