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

Charles Constant charles at charlesism.com
Thu Feb 4 10:38:18 CST 2016


I still vote for keeping "cases"

I see it as a replacement for dictionary literal "pattern matching":
> [1 : "one", 2 : "two", 3 : "three"][1] ?? "undefined"
>

A dictionary needs keys that are Hashable. A dictionary produces an
optional. We've discussed this, and more, earlier in the thread.

Even though it would be nice to have but I don’t think that I would use it
> frequently.
>

Granted, it's a bit ugly, but given the choice, I would pick "cases" over
"case case case case ..." every time.

In addition, to be more consistent with "case", "cases" would introduce
> pattern matching which doesn’t seem right with this concise syntax.
>

I haven't thought this through. It just bums me out a little to replace the
switch with something that still has imho unnecessary verbosity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/9e8203b3/attachment.html>


More information about the swift-evolution mailing list