public function sum(callable $func = null)
    {
        $sum = 0;
        $iterator = $this->getSelectIteratorOrInnerIterator($func);
        foreach ($iterator as $value) {
            if (!is_numeric($value)) {
                throw new UnexpectedValueException("sum() only works on numeric values.");
            }

            $sum += $value;
        }
        return $sum;
    }