-
Notifications
You must be signed in to change notification settings - Fork 9
Variables
impworks edited this page Oct 11, 2014
·
3 revisions
Like in most programming languages, a variable in LENS is a lexical name that represents a value of a particular type. LENS supports mutable and immutable variables.
Mutable variables are defined using the var
keyword, followed by an expression to initialize the variable with:
var one = 1
var three = one + 2
var str = "hello world"
A mutable variable can also be declared by specifying a type. Then the default value for a type is used:
var a : string // ""
var b : int // 0
var c : Point // Point(0, 0)
Immutable variables are defined using the let
keyword. They ensure that the value is assigned only once and will not change over time. Unlike a constant in C#, an immutable variable may be initialized with an expression evaluated during runtime.
let x = 1 + 2
let y = doStuff ()
Immutable variables cannot be passed to a function as a ref
argument.