Ds\Set::sum

(PECL ds >= 1.0.0)

Ds\Set::sumReturns the sum of all values in the set

Descripción

public Ds\Set::sum(): int|float

Returns the sum of all values in the set.

Nota:

Arrays and objects are considered equal to zero when calculating the sum.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

The sum of all the values in the set as either a float or int depending on the values in the set.

Ejemplos

Ejemplo #1 Ds\Set::sum() integer example

<?php
$set
= new \Ds\Set([1, 2, 3]);
var_dump($set->sum());
?>

El resultado del ejemplo sería algo similar a:

int(6)

Ejemplo #2 Ds\Set::sum() float example

<?php
$set
= new \Ds\Set([1, 2.5, 3]);
var_dump($set->sum());
?>

El resultado del ejemplo sería algo similar a:

float(6.5)
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top