See Original text in context
method eager() is nodal
Interprets the invocant as a Any, evaluates it eagerly, and returns that Any.
my = 1..5;say ; # OUTPUT: «1..5»say .eager; # OUTPUT: «(1 2 3 4 5)»
See Original text in context
method eager(::?CLASS: --> List)
Returns an eagerly evaluated List based on the invocant sequence, and marks it as consumed. If called on an already consumed Seq
, throws an error of type X::Seq::Consumed.
my = lazy 1..5;say .is-lazy; # OUTPUT: «True»say .eager; # OUTPUT: «(1 2 3 4 5)»say .eager;CATCH# OUTPUT: «Throws exception if already consumed»
See Original text in context
multi method eager(List: --> List)
Evaluates all elements in the List
eagerly, and returns them as a List
.
my \ll = (lazy 1..5).cache;say ll[]; # OUTPUT: «(...)»say ll.eager # OUTPUT: «(1 2 3 4 5)»