Skip to main content

Lists

Lists are a structure holding a sequence of items of the same type. Lists are similar to Collections, but its elements are computed when the list is constructed. Lists provide additional capabilities compared to collections, at a cost in performance, memory usage and different behaviours in error handling.

To build a list:

[1, 2, 3]

This example defines a list of three elements of type int.

All elements of a list must be of the same type.

Refer to the List library documentation for additional operations on lists.

When to use collections versus lists‚Äč

Collections and lists have different characteristics.

  • Bcause a list is materialized, it is possible to access elements by position using the List.Get operation. This feature does not exist for collections.
  • Collections have a smaller memory footprint than lists, and in general should be preferred for larger datasets.
  • Because lists are materialized, a list can be in an error state. That is, it is possible to check if a list failed to compute. This feature does not exist for collections. Instead, a collection will fail while it is being consumed. This can have an impact when developing code that handles errors. Refer to the section on Error handling for additional details.