delete
Table of Contents
Overview
The delete function deletes a specified element, or a specified value (along with the key) from a collection.
Syntax
The following syntax is used for deleting an element from index-value collection:
<collectionVariable>.delete(<value>);
(OR)
The following is applicable for deleting an element using its key from key-value collection:
<collectionVariable>.delete(<element>);
where,
Parameter | Data type | Description |
<collectionVariable> | COLLECTION | The variable in which a key value pair or an element will be deleted. |
<value> | - | The value which will be deleted along with the key. No action is taken if the specified value is not found. |
<element> | - | The element which will be deleted. No action is taken if the specified element is not found. |
Note:
- Learn about deleteKeys function that deletes specified elements, or keys.
- Learn about deleteKey function deletes an element based on a specified index, or a specified key along with its value
Example
To delete an element:
products = Collection("Creator", "CRM", "Campaigns"); products.delete("CRM"); info products;// Returns "Creator,Campaigns"
To delete a value along with the key:
productVersion = Collection("Creator" : 5, "CRM" : 2); productVersion.delete(2); info productVersion; // Returns {"Creator":5}