Skip to content

Add except(), returns a sequence with values except those passed#59

Merged
thekid merged 2 commits into
masterfrom
feature/except
Sep 28, 2025
Merged

Add except(), returns a sequence with values except those passed#59
thekid merged 2 commits into
masterfrom
feature/except

Conversation

@thekid

@thekid thekid commented Sep 28, 2025

Copy link
Copy Markdown
Member

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

thekid commented Sep 28, 2025

Copy link
Copy Markdown
Member Author

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.

1 participant