diff --git a/readme.md b/readme.md index e0cb5a9..ce6dc8f 100644 --- a/readme.md +++ b/readme.md @@ -223,24 +223,29 @@ fn(mixed $carry, mixed $value, mixed $key): mixed ### Filtering: `filter` +Create a generator that yields only the items of the input collection that the predicate returns _truthy_ for. + ```php use Dakujem\Toru\Itera; Itera::filter(iterable $input, callable $predicate): iterable ``` -Filter elements out based on a callable predicate. -When the predicate returns _falsey_, the element is rejected. +Accept and eliminate elements based on a callable predicate. +When the predicate returns _truthy_, the element is accepted and yielded. +When the predicate returns _falsey_, the element is rejected and skipped. The predicate signature is ```php fn(mixed $value, mixed $key): bool ``` +Similar to `array_filter`, `iter\filter`. + > > Sidenote > -> Native CallbackFilterIterator may be used for similar results +> Native `CallbackFilterIterator` may be used for similar results: > ```php > new CallbackFilterIterator(Itera::toIterator($input), $predicate) > ```