list pattern
A pattern in square brackets that matches a sequence element by element, where two dots (..) stand for any run of elements.
In more detail
It can also capture elements into variables while matching. ids is [1, .., 3] asks whether an array starts with 1 and ends with 3; [var first, ..] captures the first element.
Related terms
- pattern matching — Testing a value against a shape, such as a type, a range or the values of its properties, and optionally extracting parts of it in the same step.
- array — A sequence of same-sized slots stored one after another in a single block of memory, so any slot can be reached by its index directly.
Taught in
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices