klyn.Object.hash
method
public native hash() as Long
Description

Returns the hash value used by associative collections.

The default implementation hashes the same recursively stored state used by Klyn's default structural equality. Cycles are supported and equal object graphs therefore produce the same hash value.

A class that defines a custom value equality through operator== must override hash() with the same fields. An object used as a key must not mutate any field participating in its equality while it is stored in a hash collection.

Returns

A stable hash value for the lifetime of this object.

Example
class Identifier:
public readonly value as Int

public Identifier(value as Int):
this.value = value

public operator==(other as Identifier) as Boolean:
return other is not null and this.value == other.value

public override hash() as Long:
return Long(this.value)