The equal method, also known as the comparator, is a special method found in all Mirelle-defined types. It checks objects equality by comparing all corresponding fields of two objects. This method is invoked when the == or != operators are applied to user-defined objects.

The default compiler-generated method signature is as follows: bool equal(T obj) .
The user can define overloaded versions of the equal method to allow comparing it to different objects.

Mirelle performs a "deep compare" on all objects. It means that objects are compared by the value they store, rather than by their location in memory:
  • strings are compared by their content
  • matrices are compared by their values
  • objects are compared by traversing all their fields
  • arrays are compared by traversing all their content

Last edited Mar 28, 2011 at 10:28 AM by impworks, version 1


No comments yet.