Open
Description
Hi,
Currently FallBackIfEmpty has the following signature:
public static IEnumerable<T> FallbackIfEmpty<T>(
this IEnumerable<T> source,
T fallback)
Does it mean if T
is a method call private static T CreateDefault()
it would be called anyway, even if source
is not empty? I think yes, it would be.
So I propose to add an overload:
public static IEnumerable<T> FallbackIfEmpty<T>(
this IEnumerable<T> source,
Func<T> fallbackFactory)
which would call it if only source
is indeed empty.
Are you willing to accept a pr from me once agreed on the principles. Thanks!