Closed rbwhitaker closed 1 year ago
This has been added to the book. That last one is not right. I cannot find any examples where you can capture the rest, and Microsoft does not show any such examples. It may be that this was explored at one point, but not included in C# 11. If so, it may appear in C# 12, since patterns seem to be a growing boy still. At any rate, I've covered what I know about it, so I'm closing this one out.
C# 11 adds list patterns. The book needs to cover this.
[]
is an empty list.[var t]
is a single-item list.[var first, ..var rest]
matches the first item and the rest into two separate variables. Doesn't have to be the last.