CompareMap

Map command

Syntax

Tells whether two maps hold the same keys with the same values. The order in which the entries were created does not matter.

CompareMap(<first>(), <second>() [, <flags>])

Parts

<first>The first map, with its parentheses.
<second>The second map, with its parentheses.
<flags>Optional. 0 (default, #AK_MATCH_EXACT) compares exactly. #AK_MATCH_FOLD_CASE ignores case in keys and in text values.

Returns

1 when the maps are equal, 0 otherwise, and 0 when they do not hold the same type.

Good to know

  • Values are compared deeply: records, lists and maps inside entries are compared field by field.
  • Any other <flags> value stops the program with "Unknown BASIC CompareMap option".
  • Reading a missing key with m("key") creates it, and the new entry then counts in the comparison.

Example

NewMap a.s()NewMap b.s()a("x") = "Hi"a("y") = "yo"b("Y") = "YO"b("X") = "hi"Console(Str(CompareMap(a(), b())))   ' 0Console(Str(CompareMap(a(), b(), #AK_MATCH_FOLD_CASE)))   ' 1
In the manual : Arrays, lists and maps