In the last couple of weeks I started encountering this new syntax in C#:
if (someObj is { })
{
do some stuff
}
so it returns bool. It seems like JavaScript a little bit. But what exactly does this check do? Is it identical to this?
if (someObj == null)
{
do some stuff
}
I know that new versions of C# contain a lot of syntactic sugar. Is this part of that? Does it have some name or something? E.g., I know that ?:
is called the ternary operator and ?.
is called the Elvis operator. But what is is { }
? Is it even an operator?
And yes, I've tried to search online before asking here, but it seems that Google refuses to find anything useful concerning the is { }
syntax, because of the braces in the request.