Operator Compare

From REALbasicWiki

Jump to: navigation, search

Adding an Operator_Compare function to a class allows you to overload the intrinsic comparison of objects in REALbasic. Recall that given two object references, the Is operator tests whether they refer to the same object. The default behavior of the = operator is to call Is. But the presence of an Operator_Compare function of matching signature allows you to overload this behavior.


The prototype is this.

Function Operator_Compare(t as Type) as Integer

There must be exactly one parameter, and it can be of any type. This allows you to define comparisons between objects of different types.


Using Operator_Compare is trickier than it looks. You can read [[1]] until the content of that article is updated and moved into the wiki.

Personal tools
related