Bindings and inference

let introduces an immutable local binding and always needs an initializer. Usually moon infers the type from that value. Write : Type when the annotation explains intent or resolves otherwise ambiguous syntax.

An immutable binding cannot be reassigned, though it may refer to a mutable reference value such as an array.

fn main() {
  let language: string = "moon"
  let letters = 4
  println("$language has $letters letters")
}
Output & diagnostics
Expected:
moon has 4 letters
Ctrl/⌘+Enter runs the current lesson.