Defining Collection Properties
Defining Collection Properties
To define list or array properties, use these property definition syntaxes:
Property MyProp as list of Type;
Property MyProp as array of Type;
Here, MyProp is the property name, and Type is either a data type class or an object class.
This example shows how to define a property for a list of %StringOpens in a new tab values.
Property Colors as list of %String;
This code shows how to define a property for an array of Doctor objects.
Property Doctors as array of Doctor;
InterSystems IRIS represents these collection properties as instances of classes in the %Collection package. These classes contain the methods and properties that you can use to work with these collections, as follows:
-
If the property is a list of strings, integers, or other data type, it is an instance of %Collection.ListOfDTOpens in a new tab.
-
If the property is a list of objects, it is an instance of %Collection.ListOfObjOpens in a new tab.
-
If the property is an array of strings, integers, or other data type, it is an instance of %Collection.ArrayOfDTOpens in a new tab.
-
If the property is an array of objects, it is an instance of %Collection.ArrayOfObjOpens in a new tab.
Do not use the %Collection classes directly as the type of a property. For example, do not create a property definition like this:
Property MyProp as %Collection.ArrayOfDT;