News for hackers. Stuff that matters.
Re:Poll: What's Your Favorite Programming Language? by halter73 on Saturday March 24, 2012 @01:10AM (#3748549)
"thing1 ?? thing2 ?? thing3 ?? bar" will return the value of the first non-null variable in the list. zmj wants something like Ruby's andand [1] instead.

andand negates the need for an explicit null check on each property in a property lookup chain, which would normally be required to avoid a potential NoMethodError or NullReferenceException.

You can create something similar [2] to andand in C# if you are willing to do property lookups using lambda expressions.

[1] http://andand.rubyforge.org/

[2] http://stackoverflow.com/a/4958550

There are no comments on this comment yet.