[swift-evolution] Proposal: Pattern Matching Partial Function (#111)

Craig Cruden ccruden at novafore.com
Thu Feb 4 08:18:09 CST 2016


I originally had them mutually exclusive but there was pushback and the fact that no harm would be done by mixing them - I did not see the reason why not to allow them.

You could have a couple cases each with several lines of code then a value, and then a few that are just key/value mappingsā€¦.  


> On 2016-02-04, at 21:14:58, Maximilian HĆ¼nenberger <m.huenenberger at me.com> wrote:
> 
> Should we allow mixing "case" and "cases"?
> 
> I don't think so since a "cases" between several "case"'s is not recognizable enough.
> 
> With the current grammar "cases" is also allowed after "case" labels:
> 
> Example (this is currently allowed):
> 
> match(3) {
>    case 1: "one"
>    case 2: "two"
>    cases 3: "three", 4: "four"
>    default: "undefined"
> }



More information about the swift-evolution mailing list