Table of Contents

Search

  1. Preface
  2. Function reference
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. System variables
  8. Datatype reference

Function Reference

Function Reference

Subscript operator (Maps)

Subscript operator (Maps)

Use a subscript operator to access the value corresponding to a given key in a key-value pair.

Syntax

To access the value corresponding to a given key in a map, use the following syntax:
map[ key ]
The following table describes the arguments in the syntax:
Argument
Description
map
Map data type. The map from which you want to retrieve the value corresponding to a key.
key
Data type of the key. The key element for which you want to retrieve the value.
You can enter any valid expression that evaluates to a key value of the map data.

Return Value

The value associated with the key in the map. The return type is the same as the data type of the value.
NULL if the key does not exist in the map.

Example

You have the following map:
country_currency = [‘England’ -> ‘Pound’, ‘France’ -> ‘Euro’, ‘Japan’ -> ‘Yen’>, ‘USA’ -> ‘Dollar’]
The following expressions use a subscript operator to access values in the map:
Input Value
RETURN VALUE
country_currency [‘Japan’]
‘Yen’
country_currency [‘India’]
NULL
country_currency [‘England’]
‘Pound’

0 COMMENTS

We’d like to hear from you!