Variables and Types
Variables let you store and manipulate data in your programs.
Variablesâ
Declarationâ
let name = "Alice" // Immutable variable
let mut age = 25 // Mutable variable
const PI = 3.14159 // Constant
Rulesâ
letcreates immutable variablesmutmakes variables mutableconstcreates compile-time constants- Variable names use
snake_case
Basic Typesâ
Numbersâ
let integer: Int = 42
let decimal: Float = 3.14
Textâ
let message: Text = "Hello, World!"
Booleanâ
let is_active: Bool = true
let is_done: Bool = false
Type Inferenceâ
Rive can often figure out types automatically:
let count = 10 // Type: Int
let price = 19.99 // Type: Float
let name = "Bob" // Type: Text
let active = true // Type: Bool
Operationsâ
Arithmeticâ
let a = 10
let b = 3
let sum = a + b // 13
let difference = a - b // 7
let product = a * b // 30
let quotient = a / b // 3
let remainder = a % b // 1
String Operationsâ
let first = "Hello"
let second = "World"
let combined = first + " " + second // "Hello World"
Comparisonâ
let a = 5
let b = 10
let equal = a == b // false
let not_equal = a != b // true
let less = a < b // true
let greater = a > b // false
What's Next?â
- Control Flow - Make decisions in your code
- Functions - Organize your code into reusable pieces