I have the following code snippet in my project (I simplified it as much as possible):
private void someFunc(bool a, bool b, bool c, int x, int y) {
if ((a || b || c) && x != 1)
{
// do something
} else if ((a || b || c) && y < 0)
{
// do else
}
}
and IntelliJ Rider IDE offers me to convert to switch statement, which then gives me this:
private void someFunc(bool a, bool b, bool c, int x, int y) {
switch (a)
{
case true or true or true when x != 1:
// do something
break;
case true or true or true when y < 0:
// do else
break;
}
}
What kind of switch syntax is this? What is true or true or true when supposed to mean, it seems super redundant? And most importantly, where did b and c go??
I didn't expect this type of reformatting, and I think it must be a fairly new language feature? I've checked the C# language documentation but didn't find an explanation for a case like this...
static void M(bool a, bool b, bool c, int x) { if ( ... ) ... }instead.oris just the pattern matching for||