rbwhitaker / CSharpPlayersGuideEarlyAccess

A place to track issues with the C# Player's Guide for patches and future editions
19 stars 0 forks source link

List patterns #641

Closed rbwhitaker closed 1 year ago

rbwhitaker commented 2 years ago

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.

rbwhitaker commented 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.