Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

let

Scope
global
action
function
policy/recall
seal/open
finish
finish function
let x = a + 3
let result = query FooCounter[deviceID: author]

let declares a new named value whose value is evaluated from an expression. All named values created with let are immutable and exclusive — their values cannot be changed after they are defined, and the name must not already exist in this or any enclosing scope. The names this and envelope are reserved.

Variables are scoped to their containing block — the action, function, policy block, if statement, etc.

let x = 3
if foo > 4 {
    let y = x + 4  // `x` is accessible from the enclosing scope, but
                   // `y` is only valid in this if block
}
// `y` no longer exists here but `x` still does