News for hackers. Stuff that matters.
Re:C# Hidden Optimizations by heresy on Tuesday October 12, 2010 @01:58AM (#1782467)
Nit: These aren't "optimizations", they're syntactic sugar.
Re:C# Hidden Optimizations by achew22 on Tuesday October 12, 2010 @02:26AM (#1782510)
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?
Re:C# Hidden Optimizations by mullr on Tuesday October 12, 2010 @03:04AM (#1782577)
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 ??.
Re:C# Hidden Optimizations by steverb on Tuesday October 12, 2010 @09:21AM (#1783224)
?? is the null coalescing operator and it's neither new nor is it hidden.

It is damned handy though.

Re:C# Hidden Optimizations by newt on Tuesday October 12, 2010 @09:24AM (#1783233)
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.