I saw this operator in use today in a code example. I must say when I figured what it does my geek side went "YES!!!!".
It resembles an old "if" abbreviation:
(condition ? true result : false result);
now what
?? does is a null check same as the SQL Servers Coalesce function. It returns the first non null parameter.
function test(class1 variable)
{
if (variable == null)
variable = new class1();
// equals to
variable = (variable ?? new class1());
}
I'm starting to use this and giving a "What!?!???" moment when they see it and a "Yes!!" moment when they figure it out to anyone who's going to look at my code from now on. :))