Incorrect operators in tuple != expansion (Chapter 11)
On page 338, there's an incorrect expansion of the !=
operator applied to tuples.
The !=
operator will return true
if any of the pairwise element comparisons find a difference, so the expansion of this:
Console.WriteLine(t1 != t2);
should be:
Console.WriteLine(t1.Item1 != t2.Item1 ||
t1.Item2 != t2.Item2 ||
t1.Item3 != t2.Item3)
The difference is the use of the ||
operator, where in the book I've got the &&
operator.
All errata