Collection type

Learn about the type that represents a lists, sets, and maps.

Collection is an abstract data type that represents a group of related elements.

The collection type is often associated with lists, sets, and maps, but it can refer to any group of items. For example, the results of a range operation and a wildcard selector are both collections.

Learn more on how to represent collections in collection literals.

List

A list is an ordered collection of elements, where each element has an index representing its position. It allows duplicates, meaning the same element can appear multiple times in the list.

See the section on lists for more details on how to represent lists.

Set

The concept of sets refers to collections of unique items, which means that any collection can be considered a set — as long as it does not contain duplicates. So whenever you see the term set, you can assume that it refers to a collection where the items are unique.

See the section on sets for more details on how to represent sets.

Map

A map is a collection of key-value pairs where each key is unique and associated with a value. Maps are also sometimes called dictionaries or associative arrays.

See the section on maps for more details on how to represent maps.