-
Notifications
You must be signed in to change notification settings - Fork 22
Eberon array initializers
vladfolts edited this page May 27, 2016
·
1 revision
Array initializers create array with specified elements as a shortcut instead of declaring array variable and initialize each element separately.
"[" expression {, expression} "]"
MODULE test;
CONST a = [1, 2, 3];
PROCEDURE passArray(a: ARRAY OF INTEGER);
END;
BEGIN
passArray(a);
passArray([123, 456]);
END test.
- all expressions used in initializers list must have the same type
- if string literal is used as expression then element's type is STRING
- array initializers can be used to define a constant in CONST section
- array initializers can be used wherever constant expression of corresponded array's type can be used