On 8/14/2020 4:24 AM, Brian Goetz wrote:> My initial preference was to make the guard logic part of the pattern;
ideally, to make “Pattern && boolean-expr” a pattern.  But this is messy, since it invites ambiguities, and not really needed in the other primary consumer of patterns, since boolean expressions can already be conjoined with &&, and flow scoping already does everything we want. The real problem is switch is too inflexible, a problem revealed when its case labels are made more powerful.  So it seems that the sensible thing to do is to make guards a feature of switch, and say a case label is one of:

     case <constant>
     case <pattern>
     case <pattern> when <guard>

Got it, thanks.

Alex

Reply via email to