Hacker News new | past | comments | ask | show | jobs | submit login

"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




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

Search: