10BC0
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4c64a16 + 93c777a commit 15a0dadCopy full SHA for 15a0dad
mathutil/mathutil.go
@@ -238,6 +238,9 @@ func Sum[T constraints.Integer | constraints.Float](numbers ...T) T {
238
// Average return average value of numbers.
239
// Play: https://go.dev/play/p/Vv7LBwER-pz
240
func Average[T constraints.Integer | constraints.Float](numbers ...T) float64 {
241
+ if len(numbers) == 0 {
242
+ return 0
243
+ }
244
var sum float64
245
for _, num := range numbers {
246
sum += float64(num)
0 commit comments