API Reference › Uuid › Uuid.new
method

Uuid.new

Uuid.new() -> string

Generates a new **v4** (random) UUID and returns it in canonical lowercase text form, e.g. 550e8400-e29b-41d4-a716-446655440000. A v4 UUID carries 122 bits of entropy drawn from the OS secure random generator, so two independently-generated IDs colliding is not something you will ever observe in practice — which is exactly what makes it a good identity for a player, a session, a networked entity, or a piece of user-created content that has no central authority to number it.

This is the default UUID constructor; Uuid.v4 is an explicit alias. Because the value is random it is **non-deterministic** — do not mint UUIDs inside the lockstep simulation, or replays and peers will diverge.

Example

program NewId {
  entry {
    let id = Uuid.new()
    print(len(id))   # 36
  }
}
← All symbols