API Reference › Hash › Hash.of
method

Hash.of

Hash.of(s) -> int

The go-to hash for a string: turns text like "grass_tile" into a fast, stable 32-bit integer handle. Hash.of is the default when you don't care which algorithm is used — currently it is Hash.fnv1a, FNV-1a over the bytes. Reach for it to key a lookup table by name, give content a compact id, or detect that a config string changed. The result is deterministic: the same string always produces the same value, on every platform and run. It is not for security — see the section note.

Parameters

sthe string to hash

Example

program TileIds {
  entry {
    let grass = Hash.of("grass_tile")   # a stable integer id for this tile name
    let water = Hash.of("water_tile")
    print(grass)
    print(water)
  }
}
← All symbols