Type System
Run has a simple type system with the following built-in types:
Integer types
Section titled “Integer types”int- platform-sized signed integeruint- platform-sized unsigned integeri32- 32-bit signed integeri64- 64-bit signed integeru32- 32-bit unsigned integeru64- 64-bit unsigned integerbyte- alias foru8, a single byte
Floating point types
Section titled “Floating point types”f32- 32-bit floating point numberf64- 64-bit floating point number
Other types
Section titled “Other types”bool- boolean value,trueorfalsestring- UTF-8 encoded string
Type inference
Section titled “Type inference”Run can infer the type of a variable from its initial value. You rarely need to write types explicitly when using short declarations.
package main
use "fmt"
pub fun main() { x := 42 // int pi := 3.14159 // f64 name := "Run" // string active := true // bool
fmt.println(x) fmt.println(pi) fmt.println(name) fmt.println(active)}When you need a specific numeric type, use an explicit type annotation:
let small i32 = 100let big u64 = 1_000_000let precise f64 = 0.1