The sink routine

Combined from primary sources listed below.

In role Iterator ( Type/Iterator )§

See primary docmentation in context for method sink.

method sink-all§

method sink-all(Iterator:D: --> IterationEnd)

Should exhaust the iterator purely for the side-effects of producing the values, without actually saving them in any way. Should always return IterationEnd. If there are no side-effects associated with producing a value, then it can be implemented by a consuming class to be a virtual no-op.

say (1 .. 1000).iterator.sink-all;  # OUTPUT: «IterationEnd␤»

The Iterator role implements this method as a loop that calls pull-one until it is exhausted.

In class Seq ( Type/Seq )§

See primary docmentation in context for method sink.

method sink§

method sink(--> Nil)

Calls sink-all if it is an Iterator, sink if the Sequence is a list.

say (1 ... 1000).sink# OUTPUT: «Nil␤»

This is something you might want to do for the side effects of producing those values.

In class RaceSeq ( Type/RaceSeq )§

See primary docmentation in context for method sink.

method sink§

method sink(--> Nil)

Sinks the underlying data structure, producing any side effects.

In class List ( Type/List )§

See primary docmentation in context for method sink.

method sink§

method sink(--> Nil) { }

It does nothing, and returns Nil, as the definition clearly shows.

sink [1,2,Failure.new("boo!"),"still here"]; # OUTPUT: «»

In class HyperSeq ( Type/HyperSeq )§

See primary docmentation in context for method sink.

method sink§

method sink(--> Nil)

Sinks the underlying data structure, producing any side effects.

In class Proc ( Type/Proc )§

See primary docmentation in context for method sink.

method sink§

method sink(--> Nil)

When sunk, the Proc object will throw X::Proc::Unsuccessful if the process it ran exited unsuccessfully.

shell 'ls /qqq';
# OUTPUT:
# (exit code 1) ls: cannot access '/qqq': No such file or directory
# The spawned command 'ls /qqq' exited unsuccessfully (exit code: 2)
# in block <unit> at /tmp/3169qXElwq line 1
#