Implement Enumerable.Reverse(TSource[])#107957
Conversation
|
Note regarding the |
|
Note regarding the |
|
Well, I tried opening in draft to avoid tagging people until I was sure tests were passing... |
| ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source); | ||
| } | ||
|
|
||
| if (source.Length == 0) |
There was a problem hiding this comment.
Nit: I would probably just have this method call the existing Reverse directly, although I see why you might have wanted to avoid a redundant type check.
There was a problem hiding this comment.
Yeah, my thought process was "I could just call Reverse, but it's not like this a complicated method or changing very often, and this is more efficient".
| T[] expected = source.ToArray(); | ||
| Array.Reverse(expected); | ||
|
|
||
| IEnumerable<T> actual = source.ToArray().Reverse(); |
There was a problem hiding this comment.
Does this test exercise the case where source is empty?
There was a problem hiding this comment.
Yes, an empty array is in the input data.
| nameof(Enumerable.Prepend), | ||
| nameof(Enumerable.ToHashSet), | ||
| nameof(Enumerable.TryGetNonEnumeratedCount), | ||
| nameof(Enumerable.Reverse), |
There was a problem hiding this comment.
I wish there was a simple way to distinguish between the different overloads, but I suppose this should suffice.
Closes #107723.