> On Jul 10, 2016, at 10:16 PM, Xiaodi Wu <[email protected]> wrote:
> Given patterns A, B, C, and D, suppose a value x matches A, C, and D, whereas
> another value y matches B and D, and a third value matches B and C. When
> evaluating x, y, or z, which statements are executed in the following switch
> statement? How many of these reach the default case? What happens if I append
> `fallthrough` at the end of case D? What happens if I move case B after case
> D? (Yes, I know it is possible to figure it out [my understanding of the
> answer to the first question is appended below], but I hope you'll agree with
> me that this is much more difficult to decipher than any switch statement
> that's currently possible.)
>
> ```
> switch x /* or y, or z */ {
> case A:
> // ...
> continue
> case B:
> // ...
> if C ~= x /* or y, or z, whichever is switched over */ {
> continue
> }
> fallthrough
I'd say it would be fair to disallow continue and fallthrough to occur in the
same clause
> case C:
> // ...
> if B ~= x /* or y, or z, whichever is switched over */ {
> continue
> }
> case D:
> // ...
> default:
> // ...
> }
> ```
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution