Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 4bc48e20 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

reverted Sum Method back to previous behavior (returning Null if the source was empty)

parent 9492b5fa
No related branches found
No related tags found
No related merge requests found
......@@ -159,9 +159,9 @@ namespace TUGraz.VectoCommon.Utils
public static T Sum<T>(this IEnumerable<T> values) where T : SIBase<T> =>
values.Sum(x => x);
public static TResult Sum<T, TResult>(this IEnumerable<T> values, Func<T, TResult> selector)
where TResult : SIBase<TResult> =>
values.Sum(value => selector(value).Value()).SI<TResult>();
public static TResult Sum<TU, TResult>(this IEnumerable<TU> values, Func<TU, TResult> selector)
where TResult : SIBase<TResult> =>
values.Select(selector).DefaultIfEmpty().Aggregate((sum, current) => sum + current);
public static T Average<T>(this IEnumerable<T> values) where T : SIBase<T> =>
values.Average(v => v.Value()).SI<T>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment