Share via


Map.lookup Method

Returns the value mapped to by a particular key value.

Syntax

public anytype lookup(anytype keyValue)

Run On

Called

Parameters

  • keyValue
    Type: anytype
    The key to find.

Return Value

Type: anytype
The value that is mapped to by the specified key.

Remarks

An exception is thrown if the key is not found in the map, so check whether the value you want to retrieve exists by using the Map.exists method.

Examples

The following example checks whether a particular style exists in a map of styles in a style sheet. If it does, a new name is substituted for the body style.

static void renameStyle(Map stylesheet, str fromName, str toName) 
{ 
    str body; 
  
    if (stylesheet.exists(fromName)) 
    { 
        body = stylesheet.lookup (fromName); 
        stylesheet.remove (fromName); 
        stylesheet.insert (toName, body); 
    } 
    else 
    { 
        info (fromName); 
    } 
}

See Also

Map Class

Map.exists Method