newSharedCollection
newSharedCollection {( ...value : any )} : collection
Parameter | Type | Description | |
---|---|---|---|
value | integer, number, string, date, time, boolean, object (shared), collection (shared) | → | Shared collection's value(s) |
Result | collection | ← | New shared collection |
Description
The newSharedCollection
command creates a new empty or prefilled shared collection and returns its reference.
Adding an element to this collection using the assignment operator must be surrounded by the use...end
structure, otherwise an error is generated (this is not necessary when adding elements using functions such as push()
or map()
because they automatically trigger an internal use...end). Reading an element without a use...end structure is, however, possible.
For more information on shared collections, please refer to the Shared objects and collections page.
If you do not pass any parameters, newSharedcollection
creates an empty shared collection and returns its reference.
You must assign the returned reference to a variable or property of the collection type.
Optionally, you can prefill the new shared collection by passing one or several value(s) as parameter(s). Otherwise, you can add or modify elements subsequently through object notation assignment (see example). If the new element index is beyond the last existing element of the shared collection, the collection is automatically resized and all new intermediary elements are assigned a null value.
You can pass any number of values of the following supported types:
- number (number, integer...). Number values are always stored as numbers.
- string
- boolean
- date
- time (stored as number of milliseconds - number)
- null
- shared object
- shared collection
Unlike standard (not shared) collections, shared collections do not support pictures and objects or collections that are not shared.
Example
mySharedCol = newSharedCollection("alpha","omega")
use(mySharedCol)
mySharedCol[1] = "beta"
end