any() public method

This method short-circuits, so if any item matches the predicate, no further items are evaluated.
public any ( callable $predicate = null ) : boolean
$predicate callable
return boolean
Beispiel #1
0
 public function testAny()
 {
     $this->assertTrue((new Stream([false, false, true, false]))->any());
     $this->assertFalse((new Stream([false, false, false, false]))->any());
     $stream = new Stream([1, 2, 3, 4, 42]);
     $this->assertTrue($stream->any(function ($value) {
         return $value == 42;
     }));
 }