let (Immutable Binding)
let declares an immutable binding. Once initialized, it cannot be reassigned. This is the default choice for variable declarations in Cangjie—preferring immutable bindings makes code easier to understand and reason about.
Immutable binding only means that the binding itself cannot point to another value. If it holds a reference to a mutable object, the object's content can still be modified.
The code on the right demonstrates three immutable bindings. text declares its type first and is assigned later—this is allowed for local variables, but the initialization must be completed before it's referenced. Try uncommenting line 10 to see what error the compiler reports when reassigning a let binding.
Note
Global variables and static member variables must be initialized at declaration time and cannot be assigned later.