Constants and Globals
Constants
Section titled “Constants”Constants use const and must be initialized immediately:
const APP_NAME: String = "Zap Demo";const MAX_RETRIES: Int = 5;Local constants
Section titled “Local constants”fun main() Int { const LIMIT: Int = 10; return LIMIT;}Global variables
Section titled “Global variables”Mutable top-level state uses global var:
global var destroyed: Int = 0;Aliases
Section titled “Aliases”Aliases let you name an existing type:
alias Score = Int;alias Name = String;Example
Section titled “Example”alias Score = Int;global var total: Score = 0;
fun add(points: Score) { total = total + points;}
fun main() Int { add(10); add(5); return total;}