-
-
Notifications
You must be signed in to change notification settings - Fork 13
IEnumerable.except() method
Marcel Kloubert edited this page Sep 30, 2015
·
6 revisions
Produces the difference between that sequence and another (s. Except()).
public function except(sequence $second
[, equality_comparer $equalityComparer = null ]) : IEnumerable;
Name | Type | Description |
---|---|---|
$second | [[sequence | Sequence]] |
$equalityComparer | [[equality_comparer | Equality comparer]] |
The other sequence.
The equality comparer that checks if two items of the sequences are the same.
The new sequence.
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues(1, 2, 3, 4, 5);
$exc = Enumerable::fromValues(4, 1);
foreach ($seq->except($exc) as $item) {
// [0] 2
// [1] 3
// [2] 5
}
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues(1, 2, 3, 4.0, 5);
$exc = Enumerable::fromValues(4, 1);
foreach ($seq->except($exc, '($x, $y) => $x === $y') as $item) {
// [0] 2
// [1] 3
// [2] 4.0
// [3] 5
}
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues(1, 2, 3, 4.0, 5);
$exc = Enumerable::fromValues(4, 1);
foreach ($seq->except($exc, function($x, $y) {
return $x === $y;
}) as $item) {
// [0] 2
// [1] 3
// [2] 4.0
// [3] 5
}