A Map to which the current (calling) Map
will be compared.
Value must not be null.
Returns
non-null rules.MapDiff object representing the result of the comparison.
get
get(key, default_value) returns value
Returns the value associated with a given search key string.
For nested Maps, involving keys and sub-keys, returns the value
associated with a given sub-key string. The sub-key is identified using a
list, the first item of which is a top-level key and the last item the
sub-key whose value is to be looked up and returned. See the nested Map
example below.
The function requires a default value to return if no match to
the given search key is found.
Either a key specified
as a string, or for nested Maps, a sub-key specified using list syntax.
default_value
default_value
Value to return if the Map
does not contain the given search key. Can be any Rules language type.
Returns
value Value corresponding to the given key, or the
default return value specified by default_value if no match to
the given key is found. Since Map contents are user-defined, the data type of
the returned value can be any Rules language type.
Example
// "c" is not a key in the supplied Map, returns default value 7.{"a":3,"b":2}.get("c",7) == 7// Default result can be any type, e.g. a list such as [1, 1].{"a":[2,7],"b":[9,12]}.get("c",[1,1]) == [1,1]// Return a list on a successful match.{"a":[2,7],"b":[9,12]}.get("b",[1,1]) == [9,12]// For nested Maps, use list ["a", "b"] to specify lookup on sub-key "b".{"a":{"b":1},"c":2}.get(["a","b"],7) == 1
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-03-04 UTC."],[],[],null,["# Interface: Map\n\n[rules](/docs/reference/rules/rules).Map\n========================================\n\ninterface static\n\nMap type, used for simple key-value mappings.\n\nKeys must be of type `rules.String`.\n\nIn addition to the methods listed below, maps have the following operators:\n\n*** ** * ** ***\n\n| Operator | Usage |\n|----------|-----------------------------------------|\n| `x == y` | Compare maps x and y |\n| `x[k]` | Index operator, get value at key name k |\n| `x.k` | Get value at key name k |\n| `k in x` | Check if key k exists in map x |\n\nMethods\n-------\n\n### diff\n\ndiff(map_to_compare) returns [rules.MapDiff](/docs/reference/rules/rules.MapDiff)\n\nReturn a [rules.MapDiff](/docs/reference/rules/rules.MapDiff) representing the result of comparing the\ncurrent Map to a comparison Map.\n\n| #### Parameter ||\n|----------------|---------------------------------------------------------------------------------------------------------------------------------|\n| map_to_compare | [rules.Map](/docs/reference/rules/rules.Map) A Map to which the current (calling) Map will be compared. Value must not be null. |\n\nReturns\n\n: `non-null `[rules.MapDiff](/docs/reference/rules/rules.MapDiff) object representing the result of the comparison.\n\n### get\n\nget(key, default_value) returns value\n\nReturns the value associated with a given search key string.\n\nFor nested Maps, involving keys and ***sub-keys***, returns the value\nassociated with a given sub-key string. The sub-key is identified using a\nlist, the first item of which is a top-level key and the last item the\nsub-key whose value is to be looked up and returned. See the nested Map\nexample below.\n\nThe function requires a default value to return if no match to\nthe given search key is found.\n\n| #### Parameter ||\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| key | (non-null [rules.String](/docs/reference/rules/rules.String) or non-null [rules.List](/docs/reference/rules/rules.List)) Either a key specified as a string, or for nested Maps, a sub-key specified using list syntax. |\n| default_value | default_value Value to return if the Map does not contain the given search key. Can be any Rules language type. |\n\nReturns\n\n: `value` Value corresponding to the given `key`, or the\n default return value specified by `default_value` if no match to\n the given key is found. Since Map contents are user-defined, the data type of\n the returned `value` can be any Rules language type.\n\n#### Example\n\n // \"c\" is not a key in the supplied Map, returns default value 7.\n {\"a\": 3,\"b\": 2}.get(\"c\", 7) == 7\n\n // Default result can be any type, e.g. a list such as [1, 1].\n {\"a\": [2, 7], \"b\": [9, 12]}.get(\"c\", [1, 1]) == [1, 1]\n\n // Return a list on a successful match.\n {\"a\": [2, 7],\"b\": [9, 12]}.get(\"b\", [1, 1]) == [9, 12]\n\n // For nested Maps, use list [\"a\", \"b\"] to specify lookup on sub-key \"b\".\n {\"a\": {\"b\": 1},\"c\": 2}.get([\"a\", \"b\"], 7) == 1\n\n### keys\n\nkeys() returns [rules.List](/docs/reference/rules/rules.List)\n\nGet the list of keys in the map.\n\nReturns\n\n: `non-null `[rules.List](/docs/reference/rules/rules.List) list of keys.\n\n### size\n\nsize() returns [rules.Integer](/docs/reference/rules/rules.Integer)\n\nGet the number of entries in the map.\n\nReturns\n\n: `non-null `[rules.Integer](/docs/reference/rules/rules.Integer) number of entries.\n\n### values\n\nvalues() returns [rules.List](/docs/reference/rules/rules.List)\n\nGet the list of values in the map.\n\nReturns\n\n: `non-null `[rules.List](/docs/reference/rules/rules.List) list of values."]]