With C# 9.0 and newer, various pattern match forms were added. Here’s an example:
Rigidbody? Rb = //...
//Style #1
if ( Rb is null ) { //<-- pattern match
}
//Style #2
if ( Rb is not null ) {
}
//Style #3
if ( Rb is { } RbVal ) {
}
My question then is, do the pattern match checks also check object lifetime and null references properly? Much like how we can’t use null propagation and instead must use the ’ == null ’ check, I’m wondering if the same goes for pattern matches.