zig/doc/langref/constant_identifier_cannot_change.zig

16 lines
236 B
Zig
Raw Normal View History

const x = 1234;
fn foo() void {
// It works at file scope as well as inside functions.
const y = 5678;
// Once assigned, an identifier cannot be changed.
y += 1;
}
pub fn main() void {
foo();
}
// exe=build_fail