/ Type Aliases
Documentation

Getting Started

Language Guide

SDL2 and Graphics

CLI Reference

Type Aliases

A type alias gives a new name to an existing type. Aliases improve readability by making the intent of a type clear from context.

Declaring a Type Alias

Use the type keyword to declare an alias.

type PlayerId = int
type Score = float
type Name = str

fn award_score(player: PlayerId, points: Score):
    print(points)

A type alias is structurally equivalent to its target type. A PlayerId and an int are interchangeable at compile time — the alias exists for documentation purposes.

← Imports SDL2 and Graphics →