public function first(callable $fn = null, $default = null)
    {
        if (is_null($fn)) {
            return count($this->items) > 0 ? reset($this->items) : $default;
        }

        foreach ($this->getIterator() as $value) {
            if (call_user_func($fn, $value)) {
                return $value;
            }
        }

        return $default;
    }
public function first(callable $fn = null, $default = null)
    {
        if (is_null($fn)) {
            return count($this->items) > 0 ? reset($this->items) : $default;
        }

        foreach ($this->getIterator() as $value) {
            if (call_user_func($fn, $value)) {
                return $value;
            }
        }

        return $default;
    }
public function first ( callable $ fn = null , $ default = null ) { if ( is_null ( $ fn ) ) { return count ( $ this -> items ) > 0 ? reset ( $ this -> items ) : $ default ; } foreach ( $ this -> getIterator ( ) as $ value ) { if ( call_user_func ( $ fn , $ value ) ) { return $ value ; } } return $ default ; }
Retrieve the first element that matches the optional callback

@param callable|null $fn
@param mixed|null    $default

@return mixed|null
Retrieve the first element that matches the optional callback