Some notes on Elvis and Other Null-Safe Operators

Mark Mahieu markmahieu at
Sat Apr 18 12:17:07 PDT 2009

On 18 Apr 2009, at 11:33, Stephen Colebourne wrote:

> Mark Mahieu wrote:
>> Which doesn't seem like much of an improvement, to me.  But I keep
>> thinking that, in the context of this proposal, a null-safe form of
>> the foreach loop might not be so bad:
>> 	for (Foo foo :? map?.get(key)) {
>> 		...
>> 	}
> I certainly think thats an interesting idea.
> However, having a null list is something that rarely comes up in the
> code I write. I think thats because I always return an empty list from
> methods and never null (something that is definitely good practice).

Yes, if I were writing the code I mentioned I would also consider  
using different data structures entirely, such as: 

That's not always an option though.  It would certainly be a fairly  
substantial change in my example.


More information about the coin-dev mailing list