Does the pattern matching also statically check that you don't try to use a failed match. What if instead of if (o is null) return; // constant pattern "null" if (!(o is int i)) return; // type pattern "int i" WriteLine(new string('*', i)); somone forgot to return, as in if (!(o is int i)) { // do something } // incorrectly try to use `o` as an int WriteLine(new string('*', i)); Rust uses the special `match` syntax t…
int i;
if (x == 3) { i = 2; }
WriteLine(i);
I'd be interested to hear the answer, though.