Skip to main content

replace (Function)

Function returns the updated map after replacing the given key-value pair only if key is present.

Syntax

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

Query Parameters

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

Example 1

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

Function returns the updated map named stockDetails after replacing the value IBM with the key 1234 if present.