diff --git a/src/main/kotlin/org/kalasim/misc/TimeUtil.kt b/src/main/kotlin/org/kalasim/misc/TimeUtil.kt index d7bd1477..2858cb5a 100644 --- a/src/main/kotlin/org/kalasim/misc/TimeUtil.kt +++ b/src/main/kotlin/org/kalasim/misc/TimeUtil.kt @@ -11,7 +11,11 @@ fun Iterable.sum(): Duration = sumOf { it } /** Compute the sum of a set of durations via a selector function.*/ fun Iterable.sumOf(selector: (T) -> Duration) = map { selector(it) }.run { - reduce { a, b -> a + b } + if(isEmpty()) { + Duration.ZERO + } else { + reduce { a, b -> a + b } + } }