'Is' pattern in pointers #4423
Answered
by
huoyaoyuan
kyoyama-kazusa
asked this question in
Q&A
-
Hello. C# allows Test code: using System;
unsafe
{
int* p = null;
delegate*<void> q = null;
if (p == null) Console.WriteLine(1);
if (p is null) Console.WriteLine(1);
if (p != null) Console.WriteLine(1);
if (p is not null) Console.WriteLine(1);
if (q == null) Console.WriteLine(1);
if (q is null) Console.WriteLine(1);
if (q != null) Console.WriteLine(1);
if (q is not null) Console.WriteLine(1);
} Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
huoyaoyuan
Feb 11, 2021
Replies: 1 comment 1 reply
-
I believe the real reason is syntax matrix completeness, because we don't have a reason to ban it. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kyoyama-kazusa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe the real reason is syntax matrix completeness, because we don't have a reason to ban it.
Allowing pointers to be handled by pattern matching is useful for nested cases like
is { PointerProp: not null }
.