The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Rene2008 (2) [Avatar] Offline
#1
On page 142 of rev 0 of the book, the book states:

“the Distinct operator uses the elements implementation of the IEquatable<T>.Equals method if the element implement the IEquatalbe<T> interface. It uses their implementation of Objec.Equals method otherwise.

I think the correct thing to say would be:

“the Distinct operator uses the default equality comparer, Default, to compare values if an IEqualityComparer is not provided”.

The problem with the book is that is says that Distinct uses IEquatable but after looking at the code using Reflector I was not able to verify that. According to me, the Distinct method uses IEqualityComparer via the “Set<TElement>” internal class. This “Set<Telement>” class appears to be a utility class used by the Distinct enumerator.

I may be wrong about this but I figure there is nothing to lose if I bring it up just to confirm.

Thanks.
Rene2008 (2) [Avatar] Offline
#2
Re: Distinct
Never mind, I just looked at the:

private static EqualityComparer<T> CreateComparer()

of the "EqualityComparer<T>"

Sorry about that. I tried to delete the message but I couldn’t find the option to do that!!