[swift-evolution] About "default" keyword in switch statement
el.hoshino at me.com
Tue Dec 6 21:20:06 CST 2016
Thanks for all of your replies, and also thanks a lot for your time discussing this topic with me.
Also especially thanks to Robert to explain the meaning of "default" in switch statement. Now I can agree keeping using "default" keyword in switch statement.
Sorry to bother you all with this topic.
Actually before I send that mail I talked about this keyword with some of my Swift developer friends, and some of them told me that they have the same trouble in using default in switch statement, while others told me that they've never thought about it because it's just what they did in C/C++ development.
So thanks to your advices, now I can explain it to my friends.
> 2016/12/07 8:48、Robert Widmann <devteam.codafi at gmail.com> のメール：
> 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
More information about the swift-evolution