Skip to content

Bindings

Ferret has three common binding forms:

  • let immutable local binding
  • let mut mutable local binding
  • const compile-time constant
let language = "Ferret"
let mut retries = 0
retries = retries + 1

Type annotations use : when needed:

let code: i32 = 200
let mut total: i64 = 0

const is for values that are fixed at compile time.

const MAX_CONNECTIONS = 128
const APP_NAME = "ferret-docs"
fn bump(mut x: i32) -> i32 {
x = x + 1
return x
}

mut on a parameter controls the local parameter binding in that function.