[swift-evolution] Remove default case in switch-case
Mustafa Yusuf
mustafa at mustafayusuf.co
Wed Dec 9 17:01:54 CST 2015
Hello all. In switch statements in swift if all the possible cases aren't covered we have to supply a default case.
let number = 10
switch number {
case 10: print("yay")
case 12: print("close")
default: print("try again")
}
My proposal is replace it with the "case _:".
let number = 10
switch number {
case 10: print("yay")
case 12: print("close")
case _: print("try again")
}
Since underscore in swift means "whatever I don't care" it suits here better than "default". Correct me If I am wrong but this is the only use for "default" keyword in swift I guess. So we can completely remove "default" keyword from the language.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151209/23032a7b/attachment.html>
More information about the swift-evolution
mailing list