The conditions in switch must be certain. I believe this should be the case for most languages you come into contact with. In other words, there should be no ambiguity between switch conditions. In D, there may be ambiguity between condition 1 and condition c. Because c is a variable, when c equals 1, it may cause unpredictable situations in the program. So the compiler simply prohibits this situation. (Although c is assigned a value of 2 here, since it is not a constant, the compiler cannot guarantee whether the variable will be changed at runtime, so it still thinks it will cause ambiguity) To put it simply, it is not allowed to appear in the switch condition variable. (A variable here refers to a quantity that can change the result of this conditional judgment. In swift, the syntax allows assigning conditional matching values to variables)
The conditions in switch must be certain. I believe this should be the case for most languages you come into contact with.
In other words, there should be no ambiguity between switch conditions.
In D, there may be ambiguity between condition 1 and condition c. Because c is a variable, when c equals 1, it may cause unpredictable situations in the program. So the compiler simply prohibits this situation. (Although c is assigned a value of 2 here, since it is not a constant, the compiler cannot guarantee whether the variable will be changed at runtime, so it still thinks it will cause ambiguity)
To put it simply, it is not allowed to appear in the switch condition variable. (A variable here refers to a quantity that can change the result of this conditional judgment. In swift, the syntax allows assigning conditional matching values to variables)
To put it simply, because
A B D
it’s wrong