Closed Igorbek closed 7 years ago
This task is to implement the following helpers for Enumerable:
Enumerable
internal static class EnumerableExtensions { public static IEnumerable<T> WithElement<T>(this IEnumerable<T> source, T element) { ... } public static IEnumerable<T> WithoutElement<T>(this IEnumerable<T> source, T element, IEqualityComparer<T> comparer = null) { ... } }
WithElement
WithoutElement
null
source
List
Array
yield return
yield break
IEqualityComparer<T>
comparer
EqualityComparer.Default
Usage:
IEnumerable<int> seq = ... IEnumerable<int> seq = seq.WithElement(10).WithoutElement(1);
@yuriyoleynikov task has been updated
implemented in #20
This task is to implement the following helpers for
Enumerable
:WithElement
must return sequence with added passed elementWithoutElement
must return sequence with added passed elementnull
as asource
, that means the collection is emptyList
orArray
or anything buffering. useyield return
/yield break
IEqualityComparer<T>
comparer
is not specified ornull
passed, use default comparer fromEqualityComparer.Default