Page last modified on July 06, 2014, at 07:52 AM

Causerie manages arrays in much the same way as Smalltalk: as a sequential list of one or more ids. Since an id is simply a reference to a class or object, and since everything in causerie is a class or object, arrays in causerie can contain any object -- and they need not even be the same.

Defining arrays

Arrays in causerie derive from the array? base class, which is defined by the compiler and managed by the runtime?. If you want to declare an array and assign it to a variable, you can do so in the same manner as any other variable:

// Define an array of odd numbers
array var oddNumbers := #(1,3,5,7,9);

// Define an array that contains elements of various types
array var menagerie := #(13, 'twenty-seven', 38.56);

As shown above, one defines the initial elements of the array by listing them in parentheses and prefixing a hash character. As with string literals and numeric constants, arrays can be coded directly into your source -- they need not be explicitly assigned to a variable. Such arrays are treated as constants: they cannot be modified or freed until the program ends.



recent changes

edit SideBar

All site content copyright © its various contributors.
Licensed under Creative Commons License