Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented Sep 28, 2025

This pull request adds an except() method to sequences.

Example

use util\data\Sequence;

$remaining= Sequence::of([1, 2, 3, 4])->except(2, 4)->toArray(); // [1, 3]

This is basically a shorthand for the following:

use util\data\Sequence;

$remaining= Sequence::of([1, 2, 3, 4])
  ->filter(fn($e) => !in_array($e, [2, 4]))
  ->toArray()
;

...but it also works for arbitrary objects, including those implementing object comparison, which in_array() does not honor.

See also

@thekid thekid changed the title Add Sequence::except() to return a sequence with values except those passed Add except(), returns a sequence with values except those passed Sep 28, 2025
@thekid thekid merged commit 4c5b587 into master Sep 28, 2025
22 checks passed
@thekid thekid deleted the feature/except branch September 28, 2025 07:48
@thekid
Copy link
Member Author

thekid commented Sep 28, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants