Skip to main content

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​

  • let creates immutable variables
  • mut makes variables mutable
  • const creates 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?​