-
-
Notifications
You must be signed in to change notification settings - Fork 13
IEnumerable.average() method
Marcel Kloubert edited this page Sep 25, 2015
·
3 revisions
Computes the average of that sequence (s. Average()).
public function average([ mixed $defValue = null ]) : mixed;
Name | Type | Description |
---|---|---|
$defValue | mixed | [OPTIONAL] The value to return if sequence is empty. |
The default value.
The average of the sequence or the default value.
use \System\Linq\Enumerable;
$seq1 = Enumerable::fromValues(1, 2, 3, 4, 5, 6);
$seq2 = Enumerable::fromValues();
// 3.5
$a1 = $seq1->average();
// 'TM', because sequence is empty
$a2 = $seq2->average('TM');