Collection Commands (Template Language)

Collection commands of Software Ideas Modeler template language.
Command Result Type Description
Add(collectionName:Name, [key:Object], value:Object) Void

Adds a value to a list or a key-value pair to a dictionary. If a key is provided, the operation targets a dictionary; otherwise, it adds to a list.

Parameters: The name of the collection, an optional key for dictionaries, and the value to add.

Example: Add(myList, "Hello") adds "Hello" to the list named "myList". Add(myDict, "greet", "Hello") adds a key-value pair to the dictionary "myDict".

Clear(collectionName:Name) Void

Removes all items from a list or all key-value pairs from a dictionary.

Parameter: The name of the collection to clear.

Example: Clear(myList) removes all items from "myList".

Get(collectionName:Name, indexOrKey:Object) Object

Returns an item from a list or a value from a dictionary based on an index or key. If the index is out of range or the key is not present, it returns null.

Parameters: The name of the collection, and the index or key of the item to retrieve.

Example: Get(myList, 1) returns the second item from "myList". Get(myDict, "greet") returns the value associated with "greet" in "myDict".

GetKeys(dictionaryName:Name) Array

Returns an array of all keys in the specified dictionary.

Parameter: The name of the dictionary.

Example: GetKeys(myDict) might return ["greet", "farewell"] for a dictionary with these keys.

GetValues(dictionaryName:Name) Array

Returns an array of all values in the specified dictionary.

Parameter: The name of the dictionary.

Example: GetValues(myDict) might return ["Hello", "Goodbye"] for a dictionary with these values.

IsInList(collectionName:Name, item:Object) Boolean

Checks whether a list contains a given value or a dictionary contains a given key.

Parameters: The name of the collection and the item (value or key) to check for.

Example: IsInList(myList, "Hello") returns true if "Hello" is an item in "myList".

Map(dictionaryName:Name, key:Object) Object

Returns the value associated with a key in a dictionary. If the key is not present, returns the key itself.

Parameters: The name of the dictionary and the key to search for.

Example: Map(myDict, "greet") returns the value for "greet" in "myDict". If "greet" is not a key, returns "greet".

Remove(collectionName:Name, indexOrKey:Object) Void

Removes an item from a list or a key-value pair from a dictionary based on an index or key.

Parameters: The name of the collection and the index or key of the item to remove.

Example: Remove(myList, 1) removes the second item from "myList". Remove(myDict, "greet") removes the "greet" key and its value from "myDict".

Union(...collections:Collection) Collection

Returns a union of the input collections, combining items from lists or key-value pairs from dictionaries into a single collection.

Parameters: A sequence of collections to unify.

Example: Union(list1, list2) combines the items from "list1" and "list2" into a new collection.

New Comment

Comment