Declarations and types
Declarations
Section titled “Declarations”Declaration of variables
Section titled “Declaration of variables”// Local variableslet name = "Alpha"
// Global (public) variablespub meaning_of_life = 42
// Reassignmentname = "blade"Typed declarations
Section titled “Typed declarations”Types allow you to explicitly describe a variable’s type. In Hybroid Live, types are not always necessary. Types might be necessary when you want to describe a complex type variable, or if the variable is left undefined. Types are what allows Hybroid Live to make sure you can write valid code without much headache and without the need to debug a lot.
number a // variable uninitialized, type requiredlet num = 1 // variable initialized, type inferredpub fn(text, bool) callback // function uninitialized, type requiredpub b = true // global variable initialized, type inferredDeclaration of constants
Section titled “Declaration of constants”const PI = 3.14fType aliases
Section titled “Type aliases”Type aliases let you create reusable names for types. See the full Type aliases page for details.
alias ID = numberpub alias Config = struct{ number hp, fixed speed }Basic types
Section titled “Basic types”number // numberfixed // fixedpoint numbertext // stringbool // booleanentity // entityfn(T) -> T // functionlist<T> // listmap<T> // map