Any.==
Group: Operators
Aliases: equals
Documentation
Checks if self
is equal to that
.
Two values are considered to be equal in Enso when they obey the following recursive properties: - At each level, they have the same structure. - The value of each field in self
is equal (by this definition) to the corresponding field in that
.
Arguments
that
: The object to compareself
with.
Examples
The string 'é' (i.e. the character U+00E9, LATIN SMALL LETTER E WITH ACUTE)
is canonically the same as the string 'e\u0301' (i.e. the letter e
followed by U+0301, COMBINING ACUTE ACCENT). Therefore:
('é' == 'e\u0301') == True
Checking if the variable a
is equal to 147
.
from Standard.Base import all
example_equality =
a = 7 * 21
a == 147
Remarks
Implementing Your Own Equality
Equality in Enso is defined to allow comparison of any two values
(universal equality), no matter if they are not directly comparable. When
implementing equality for your own types, keep in mind that it needs to
work with any Enso value as the that
argument.
Unicode Equality
The definition of equality includes Unicode canonicalization. I.e. two texts are equal if they are identical after canonical decomposition. This ensures that different ways of expressing the same character in the underlying binary representation are considered equal.
Generic Equality and Performance
While the generic equality provided here will work for all values in Enso, its performance may often be suboptimal. Many types can implement their own equality operations that will be more efficient than these.