On Monday, 15 August 2022 at 02:23:34 UTC, Ali Çehreli wrote:
Wow! Are people actually working on those? :)
Absolutely. Thanks for the book. I'm enjoying it.
At first, I couldn't even get the code to compile due to
const-correctness issues with opCmp. :/ I used the following
cast():
foreach (i, point; points) {
immutable comparison = (cast()point).opCmp(rhs.points[i]);
// ...
}
For some reason I didn't have this problem.
The bug was with trying to implement that unnatural "ignore the
color" in the comparison logic but then toHash was taking
advantage of existing array hashing code, which had no idea of
the programmer's requirement:
I thought that was the problem, but wasn't sure. I wasn't
getting the same hash code for area1 and area2.
Your solution worked. I guess it is a little unnatural to ignore
the color. I tried overriding the toHash() of Point, but I don't
know enough D to get it to work. I wonder if that could be a
solution.
Thanks so much for the reply.