[swift-evolution] [Pitch] Can we make `default` on switches optional?

Jeremy Pereira jeremy.j.pereira at googlemail.com
Thu Oct 6 04:52:55 CDT 2016


> On 5 Oct 2016, at 15:29, Haravikk via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> I agree with Tim; I'm a +1 for switch! for a convenient means of erroring out, but I think switch? is a bit too different from normal usage of the question-mark.
> 
> One other alternative might be if there could be some kind of switch else syntax, kind of like a guard statement, allowing options on what to do? Only problem is how best to structure it, as the use of break might confusing as to its scope, like so:
> 
> 	switch(foo) else break { // Break from the switch, or the enclosing block?

We already have that in default, The syntax is different, but at least the meaning of break is unambiguous. 



More information about the swift-evolution mailing list