skip()¶
The skip operator processes a stream source by discarding the first N items and yielding all subsequent items.
- class RunOpenCode\Component\Dataset\Operator\Skip¶
- __construct(iterable<TKey, TValue> $source, positive-int $count)¶
- Parameters:
$source –
iterable<TKey, TValue>Stream source to iterate over.$count –
positive-intNumber of items to skip.
- getIterator()¶
- Returns:
\Traversable<TKey, TValue>Items from the stream source after first$countitems.
Use cases¶
When first N items needs to be skipped.
Example¶
1<?php
2
3new Stream(['a' => 1, 'b' => 2, 'c' => 3])
4 ->skip(2); // yields 'c' => 3