Here's one more question:

Before I knew that opEquals existed, I tried overloading the equality expressions (== and !=) in opBinary using the code below. It worked. Why would the overloaded opBinary version get called if the equality expressions are held in opEquals? I'm just interested in knowing how dmd chooses where to take an expression from if it lies in multiple places (e.g. == in opEquals and opBinary), even if what I did was just add the == operator to opBinary. (Is that what I did there?)

override bool opBinary( string op ) ( Rect r ) if( op == "==" ) {
                //Check if rectangle coordinates are equal
if( left == r.left && right == r.right && top == r.top && bottom == r.bottom ) {
                        return true;
                } else {
                        return false;
                }
        }


Thanks!

Reply via email to