[swift-evolution] [Pitch] Introduce continue to switch statements

Erica Sadun erica at ericasadun.com
Mon Jul 11 10:15:35 CDT 2016


> On Jul 11, 2016, at 7:27 AM, Rob Mayoff <mayoff at dqd.com> wrote:
> 
> Just to be clear, under your proposal, what does the following program
> print? Can you make an argument in favor of your interpretation?
> 
>    var x = 1
>    switch x {
>    case 1:
>        print("one")
>        x = 2
>        continue
>    case 2:
>        print("two")
>    default:
>        break
>    }

The switch statement is defined as:

switch-statement → switch expression {switch-cases*}

I'd imagine this means the expression is evaluated once, e.g.:

switch 2 + 3 {
case 5: print("Five!")
default: break
}

So I'm more likely to expect "one" than "one"/"two".  I would defer this question 
to the core team for a better answer.

-- E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160711/3eac633b/attachment.html>


More information about the swift-evolution mailing list