C
C#9mo ago
cypherpotato

✅ Disjunctive patterns negation

Hey there. I was wondering why my disjunctive is not working as intended:
authUser.Level
> Internal
authUser.Level is UserLevel.Administrator
> false
authUser.Level is UserLevel.Internal
> true
authUser.Level is not UserLevel.Administrator or UserLevel.Internal
> true
authUser.Level
> Internal
authUser.Level is UserLevel.Administrator
> false
authUser.Level is UserLevel.Internal
> true
authUser.Level is not UserLevel.Administrator or UserLevel.Internal
> true
The last expression result doesn't make sense for me, because I'm checking if authUser.Level is not Administrator or Internal, and it actually is Internal as shown in the first expression, so the result should be false. What i'm doing wrong?
10 Replies
Keswiik
Keswiik9mo ago
probably need to use parenthesis around your or for the not to function as expected
cypherpotato
cypherpotatoOP9mo ago
C# Online Compiler | .NET Fiddle
Test your C# code online with .NET Fiddle code editor.
cypherpotato
cypherpotatoOP9mo ago
but why putting an parenthesis on it? does (UserLevel.Administrator or UserLevel.Internal) produces an enum with equality to both values or am i missing something else?
Keswiik
Keswiik9mo ago
Because your example shows that it is clearly matching against not UserLevel.Administrator and UserLevel.Internal
cypherpotato
cypherpotatoOP9mo ago
so the ideal, without the parenthesis, would be authUser.Level is not UserLevel.Internal and not UserLevel.Administrator?
Keswiik
Keswiik9mo ago
correct
cypherpotato
cypherpotatoOP9mo ago
pretty confusing but that's it, thank you
Keswiik
Keswiik9mo ago
:PepoSalute:
Denis
Denis9mo ago
$close
MODiX
MODiX9mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server