put()
Table of Contents
Overview
The put() function takes mapVariable, key and value as arguments, and adds the key-value pair to the mapVariable.
Syntax
<mapVariable>.put( <key>, <value> );
Parameter | Description | Data type |
---|---|---|
<mapVariable> | The map to which the key-value pair will be added. | KEY-VALUE |
<key> | The key to be added to the map. If a duplicate key is specified, its new value will overwrite its existing value, and the new key-value pair will not get added. | KEY-VALUE |
<value> | The value to be added to the map. | AS APPLICABLE |
Examples
Products = map();
Products.put("Creator", 4);
Products.put("CRM", 3);
Products.put("Creator", 5); // Now the map will contain {"Creator" : 5, "CRM" : 3}
Products.put("Creator", 4);
Products.put("CRM", 3);
Products.put("Creator", 5); // Now the map will contain {"Creator" : 5, "CRM" : 3}