Closed
Description
Our samples on pattern matching are correct, and we mention that null
doesn't match any type in an is
or case
pattern matching expression.
this topic should add a paragraph or two explaining the behavior for null
. We can expand with the justifications:
- The existing
is
expression always returnedfalse
fornull
. It is more consistent for the new extensions to have the same semantics on null. - Having
null
never match a type means that developers do not need the explicit null check after matching a pattern. That is a factor in favor of this design. - If non-nullable types are added to the language, this decision will make everyone happy.