5.4 Equality
See also Equatables.
The == map configuration can be used with forms like the Map.by constructor or Map.by annotation constructor to specify the default equality and hashing functions for map keys. The Map.by(==) annotation, for example, matches only maps that use the default equality and hashing functions.
> "apple" == "apple"
#true
> [1, 2, 3] == 1
#false
> [1, "apple", {"alice": 97}] == [1, "apple", {"alice": 97}]
#true
> 1 == 1.0
#false
The === map configuration can be used with forms like the Map.by constructor or Map.by annotation constructor to specify key equality with === and a corresponding hashing function.
#true
#false
operator | ||
| ||
| ||
operator | ||
|
These comparisons are specialized like + for arguments with Flonum static information.
> 1 .= 1
#true
> 1 .= 2
#false
> 1.0 .= 1
#true
> 1 .!= 2
#true
> 1 .!= 1.0
#false
> "apple" != "apple"
#false
operator | ||
| ||
| ||
expression | ||
| ||
repetition | ||
| ||
map configuration | ||
Mutable and immutable strings, byte vectors, and arrays are considered the same if they have the same elements, even if one is mutable and the other is immutable. However, a mutable map or set is never considered equivalent to an immutable map or set, even if they have the same content.
The is_now map configuration can be used with forms like the Map.by constructor or Map.by annotation constructor to specify key equality with is_now and a corresponding hashing function. Beware, however, that mutating a key after it is mapped will tend to make the map entry inaccessible.
> #"apple" is_now Bytes.copy(#"apple")
#true
> #"apple" == Bytes.copy(#"apple")
#false
operator | |||
| |||
| |||
map configuration | |||
expression | |