coalescing

Unique ways to use the Null Coalescing operator

I know the standard way of using the Null coalescing operator in C# is to set default values. string nobody = null; string somebody = "Bob Saget"; string anybody = ""; anybody = nobody ?? "Mr. T"; // returns Mr. T anybody = somebody ?? "Mr. T"; // returns "Bob Saget" But what else can ?? be used for? It doesn't seem as useful as t...

How to write a proper null-safe coalescing operator in scala?

Having seen the answers coming out of questions like this one involving horror shows like trying to catch the NPE and dredge the mangled name out of the stack trace, I am asking this question so I can answer it. Comments or further improvements welcome. ...