You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation of switch says that it must be exhaustive, but what does that mean is not defined in the docs as far as I can tell.
For example, this one is exhaustive:
letn=[-1,1].randomElement()!
switch n {caseInt.min..<0:print("negative")case0...Int.max:print("non-negative")}
but it does not compile. Neither does
letn=[-1,1].randomElement()!
switch n {case n where n <0:print("negative")case n where n >=0:print("non-negative")}
Of course, you can try and add a dummy default if the compiler does not handle that case. But in any case my point is that, formally, ideally, what exhaustive means should be in the language reference.
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 0e0108912719ea3c1df9d770256405e7
Issue Description:
The documentation of
switch
says that it must be exhaustive, but what does that mean is not defined in the docs as far as I can tell.For example, this one is exhaustive:
but it does not compile. Neither does
Of course, you can try and add a dummy
default
if the compiler does not handle that case. But in any case my point is that, formally, ideally, what exhaustive means should be in the language reference.The text was updated successfully, but these errors were encountered: