I've found a way to encode the null pattern if you have a record

record Foo(int x) { }

Foo foo = ...
return switch(foo) {
  case Foo(int _) foo -> "i'm a foo not null here !";
  case Foo fooButNull -> "i can be only null here !"; 
};

I wonder if allowing those two patterns, a record pattern and a type pattern 
using the same type is a good idea or not, it seems a great way to obfuscate 
thing.

RĂ©mi

Reply via email to