List Manipulations
The Create List Deluge syntax enables the creation of new list. A new list can be created in two ways:
- Using constructor.
- Using list functions that return list values as output / or by direct assignment of one list to another.
Using constructor
A constructor is a special syntax provided to create a list. These constructors also supports special qualifiers that enables the creation of specific list like string-list or date-list that accepts only string or date type values respectively. A constructor enables the creation of both empty list and also list with some initial values. The constructors for creating a list variable are given below:
- {} - Holds list values of any type. Handy syntax for creating list with some initial values.
- List() - Holds list values of any type.
- List:String() - Holds list values of type String.
- List:Int() - Holds list values of type Integer.
- List:Date() - Holds list values of type Date.
- List:Bool() - Holds list values of type Boolean - true/false.
- List:Float() - Holds list values of type Float.
Using list functions that return list values as output / or by direct assignment of one list to another
A new list can be created by using methods like sublist(), toList() etc. that return a list as output. You can also create a new list by directly assigning an already defined list to it. In these cases, the new list created is usually not empty.
Syntax
<listname> = <listexpression/constructor>;
where,
<listname> - any user-defined name can be specified as list name.
<listexpression/constructor> - the expression, value or list constructor to initialize the list.
Example
In the following sample code, a List named list1 of type String is defined in the on add -> on load block and initialized with the List:String() constructor.
list1 = List:String();
In the following sample code,
- a string list named list2 is defined in the on add -> on load block and initialized with string values.
- a general list named list3 is defined in the on add -> on load block and initialized with string and number values.
list2 = List:String({"hockey", "cricket", "football", "tennis"});
list3 = {1, 2, 3, 4, "party"};
In the following sample code, a string list named list4 is defined and initialized with the Deluge expression input.Country+input.Name
list4 = List:String({input.Country + ", " + input.Name}); }