"New switch"'s bug
#10095
I used debug compilation mode + debuging + VS 2026 |
Answered by
FaustVX
Apr 10, 2026
Replies: 1 comment 1 reply
|
It's not a bug, the If you put the expression in parenthesis, it works as you intended : public int ArraySizeDelta1
{
get
{
int delta = LeftPoint.ArraySizeDelta + RightPoint.ArraySizeDelta; // 1 + 1 = 2
return delta switch
{
0 => 0,
> 0 => 1, // correct, returns 1
< 0 => -1,
};
}
}
public int ArraySizeDelta2
{
get
{
return (LeftPoint.ArraySizeDelta + RightPoint.ArraySizeDelta) switch // 1 + 1 = 2
{
0 => 0,
> 0 => 1, // correct choice, but returns 2
< 0 => -1,
};
}
} |
1 reply
Answer selected by
jnm2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not a bug, the
switch expressiontakes precedence over the+.If you put the expression in parenthesis, it works as you intended :