Map type
  • 28 Nov 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Map type

  • Dark
    Light

Article summary

A map is similar to a list that contains multiple values, but contrary to a list it is not ordered. Instead, the items of a map can be accessed with a key, which is stored alongside each value in the map. In other words: keys are mapped to values, which is where the name "map" comes from.

Keys and values can be of any type, so long as all keys have the same type and all values also have the same type.

Existing maps

It is not yet possible to create maps in rules, but you can use the maps that already exist in your configurator.

These components have maps that you can work with:

  • Graphic component has two maps: visuals and dynamic visuals
  • Resource component has a resource map
  • Checkout component has a shops map

There are two more maps in every configurator:

  • The configurator has a components map
  • presets.All is a map of all your presets

Functions

namedescription
lengthgets the number of items in the map
get(key)
gets the value for a specified key

length

Returns the number of items in the map.

exampledescription
components.length()gets the number of components in your configurator

get(key)

Returns the value for a specified key, or empty if the map contains no such key.

exampledescription
myResourceComponent.Resources.Get("resource1")get a resource by name

When looking for keys, get uses the default equality operator as defined by the type of the keys in the map.

All pre-defined maps have text keys, which are compared case-sensitive.



Was this article helpful?

What's Next