Primitive Types
Vertex has eight built-in types:
| Type | Literal | Example |
|---|---|---|
Int | plain integer | 42 |
Long | integer with L suffix | 100L |
Double | decimal point, no suffix | 3.14 |
Decimal | decimal with d suffix | 9.99d |
Bool | true or false | true |
String | double-quoted | "hello" |
Id | no literal. Comes from Salesforce DML | , |
Void | the keyword Void | Void |
Numbers
Section titled “Numbers”let age: Int = 30let population: Long = 8000000000Llet price: Decimal = 19.99dlet ratio: Double = 0.75
debug age + 5 // 35debug price * 2.0d // 39.98Strings
Section titled “Strings”Strings use double quotes and support interpolation:
let name = "Alice"let age = 30debug "Hello, ${name}! You are ${age} years old."Any expression is valid inside ${}:
debug "${2 + 2}" // 4debug "area: ${3.14 * 5.0 * 5.0}"String + coerces the right-hand side automatically:
debug "count: " + 42 // "count: 42"Void is a first-class value. Not just an absence of a return type. A function
that only performs side effects declares : Void and ends with Void as its
last expression:
fn log(message: String): Void { debug message Void}Type annotations
Section titled “Type annotations”Type annotations on local bindings are optional when the type can be inferred:
let x = 42 // Int, inferredlet y: Int = 42 // Int, explicit. Same thing