skip
ErrorsCollection

skip

Synthesised documentation from type/Supply type/Any type/Test type/Seq

From type/Supply

See Original text in context

method skip(Supply:D: Int(Cool$number = 1 --> Supply:D)

Returns a new Supply which will emit all values from the given Supply except for the first $number values, which will be thrown away.

my $supplier = Supplier.new;
my $supply = $supplier.Supply;
$supply = $supply.skip(3);
$supply.tap({ say $_ });
$supplier.emit($_for 1..10# OUTPUT: «4␤5␤6␤7␤8␤9␤10␤» 

From type/Any

See Original text in context

multi method skip()
multi method skip(Whatever)
multi method skip(Callable:D $w)
multi method skip(Int() $n)

Creates a Seq from 1-item list's iterator and uses Seq.skip on it, please check that document for real use cases; calling skip without argument is equivalent to skip(1).

Calling it with Whatever will return an empty iterator:

say <1 2 3>.skip(*);   # OUTPUT: «()␤»

The multi that uses a Callable is intended mainly to be used this way:

say <1 2 3>.skip(*-1); # OUTPUT: «(3)␤»

Instead of throwing away the first $n elements, it throws away everything but the elements indicated by the WhateverCode, in this case all but the last one.

From type/Test

See Original text in context

multi sub skip()
multi sub skip($reason$count = 1)

Skip $count tests, giving a $reason as to why. By default only one test will be skipped. Use such functionality when a test (or tests) would die if run.

sub num-forward-slashes($arg{ ... } ;
 
if $*KERNEL ~~ 'linux' {
    is num-forward-slashes("/a/b"),             2;
    is num-forward-slashes("/a//b".IO.cleanup), 2;
}
else {
    skip "Can't use forward slashes on Windows"2;
}

Note that if you mark a test as skipped, you must also prevent that test from running.

From type/Seq

See Original text in context

multi method skip(Int() $n = 1 --> Seq)

Returns a Seq containing whatever is left of the invocant after throwing away $n of the next available values. Negative values of $n count as 0. Also can take a WhateverCode to indicate how many values to skip from the end. Will block on lazy Seqs until the requested number of values have been discarded.

say (1..5).map({$_}).skip;      # OUTPUT: «(2,3,4,5)␤» 
say (1..5).map({$_}).skip(3);   # OUTPUT: «(4,5)␤» 
say (1..5).map({$_}).skip(5);   # OUTPUT: «()␤» 
say (1..5).map({$_}).skip(-1);  # OUTPUT: «(1,2,3,4,5)␤» 
say (1..5).map({$_}).skip(*-3); # OUTPUT: «(3,4,5)␤»