Operator { } Foundation

Literal array: encloses values for literal arrays.

{ <Expression,...> }
<Expression,...> is a comma separated list containing optional expressions. The expressions are evaluated before the literal array is created. After it has been created, the array contains as its elements the values of the expressions.

Within program code, the curly braces enclose a literal array. An array is a data type which can store multiple values. The various values of an array are stored in its array elements. All expressions within the curly braces are evaluated at runtime before each is stored in the array as an array element. This can be used to initialize array elements with default values.

Literal arrays are generally used with the inline assignment operator. This assigns the array to a variable immediately after its variable declaration by referencing a literal array containing values in its elements.

When a variable is declared STATIC and initialized to a literal array, the expressions in the literal array list <Expression,...> must contain only constant values and may not contain function calls. STATIC variables can only be initialized to values known at compile time.

The literal array
// This example demonstrates how variables are initialized 
// in their declaration using literal arrays. 

   STATIC saFiles := ;              // assign literal array 
            { "CUSTOMER.DBF", ;     // of constant values 
              "INVOICE.DBF",  ;     // to STATIC variable 
              "ARTICLE.DBF" } 

   LOCAL aLogin := ;                // assign literal array 
            { Time(), Date() }      // with expressions 
                                    // to LOCAL variable 

   LOCAL aArray := ;                // assign multidimensional 
            { ;                     // array with changing 
              { 1, 2 }, ;           // values to LOCAL variable 
              {"James", "Bond"}, ; 
              .T., ; 
              Directory(), ; 
              Date() ; 

   Aeval( aLogin , {|x| QOut(x) } ) // output log in time 
                                    // open files 
   Aeval( saFiles, {|c| DbUseArea(.T., , c )} ) 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.