[swift-evolution] About "default" keyword in switch statement

Robert Widmann devteam.codafi at gmail.com
Tue Dec 6 17:48:52 CST 2016


Perhaps you're thinking about this choice of syntax from a different angle than was intended.  `default` is not literally meant to be a "default value" or, in most cases, "the default case", rather a "default pattern"; a place for control to flow given no other option.  Some other languages, especially those that emphasize patterns, syntaxize words like "otherwise" or simply use "_", but I've not seen languages that mix C-style switch-case keywords with C-style branching keywords before.

~Robert Widmann

2016/12/05 22:48、星野恵瑠 via swift-evolution <swift-evolution at swift.org> のメッセージ:

> Many languages have a switch statement and most (maybe all?) of them use "default" keyword for the condition which doesn't match any of those listed in the switch statement.
> 
> But sometimes that condition is just an exception, which literally IS NOT a default condition.
> 
> So how about using other keywords like "else" instead of "default"?
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list