I am not too familiar with OrderedEnumerable, but while making changes during dotnet/corefx#14174 I noticed there was a discrepancy between Last and LastOrDefault.
Code in Last: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L416. The result of comparer.Compare is compared with >= to 0.
Code in LastOrDefault: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L447 The result of comparer.Compare is compared with > to 0.
I assume this is trying to somehow find the maximum value of the enumerable? If that is the case, is the latter version correct?
cc @JonHanna @VSadov
I am not too familiar with
OrderedEnumerable, but while making changes during dotnet/corefx#14174 I noticed there was a discrepancy betweenLastandLastOrDefault.Code in
Last: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L416. The result ofcomparer.Compareis compared with>=to 0.Code in
LastOrDefault: https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L447 The result ofcomparer.Compareis compared with>to 0.I assume this is trying to somehow find the maximum value of the enumerable? If that is the case, is the latter version correct?
cc @JonHanna @VSadov