8000 FallbackIfEmpty overload with fallback factory · Issue #293 · morelinq/MoreLINQ · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
FallbackIfEmpty overload with fallback factory #293
Open
@abatishchev

Description

@abatishchev

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0