Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nit: These aren't "optimizations", they're syntactic sugar.


I'm far from impressed with this. How is ?? any different from a guard ( || )? I use that all the freaking time in every language. I've never written a line of C# and even I know about the parallel module, how didn't that make the cut?


C# has || just like any other language, but objects aren't truthy and nulls aren't falsy. This was a good design decision, since it catches the common = vs. == error if(a=b) while doing the type check rather than silently doing the (probably) wrong thing. As a consequence, the || doesn't work as it does in other places. Hence ??.


?? is the null coalescing operator and it's neither new nor is it hidden.

It is damned handy though.


Every language?

Java, as far as I know, does not allow if (someObject) where someObject is a class type. AFIAK, java only allows that if someObject is a bool, or possibly an int as well.

In strongly typed languages in general, null is not the same thing as false and not-null is not the same thing as true.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: