Skip to main content

putIfAbsent (Function)

Function returns the updated map after adding the given key-value pair if key is absent.

Syntax

<OBJECT> map:putIfAbsent(<OBJECT> map, <INT|LONG|FLOAT|DOUBLE|BOOL|STRING> key, <INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
mapThe map to which the value should be added.OBJECTNoYes
keyThe key to be added.INT LONG FLOAT DOUBLE BOOL STRINGNoYes
valueThe value to be added.INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Example 1

map:putIfAbsent(stockDetails , 1234 , 'IBM')

Function returns the updated map named stockDetails after adding the value IBM with the key 1234 if key is absent from the original map.