Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator Last Altered:
Property [other Property type actions]
Item [operators of similar scope]
Dictionary, Set & List operations [other Dictionary, Set & List operations operators]
Baseline
As at baseline
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
Dictionary.keys()
Dictionary.keys
A List-type property. Returns a list of unsorted key names (i.e. only the keys' strings and not those of values) for this note. Unlike a List or Set, the Dictionary cannot be iterated directly using .each(). Instead, Dictionary.keys provides an iter-able list. So:
$MyDictionary.keys.each(x){
if($MyDictionary[x] == "Whoops"){
...
}
}
Therefore do not try: $MyDictionary.each(x)
A dictionary cannot be sorted but as above Dictionary.keys can be sorted. This is the previous example above, but with an added .sort operator inserted after .keys:
$MyDictionary.keys.sort.each(x){
if($MyDictionary[x] == "Whoops"){
...
}
}
Note that when iterating a dictionary with .each(X) the loop variable X is the String value of the key.
Depending on your needs you might prefer to pass the dictionary explicitly to a list attribute before doing further work:
$MyList = $MyDictionary.keys; // then work with MyList