Regarding null safe oprators
Reinier Zwitserloot
reinier at zwitserloot.com
Wed Jul 15 18:00:43 PDT 2009
Amen; null lists are a mistake (or at least, if you try to treat them
as an actual list). A 'maybe' utility method as Paulo Levi showed is
more than sufficient to address the use case. One could make a case
for adding this to java.util.Collections.
--Reinier Zwitserloot
On 2009/16/07, at 01:49, Paulo Levi wrote:
> Someone on another message on this very topic sent this method:
> public static <E> Iterable<E> maybe(Iterable<E> iterable) {
> return iterable == null ? Collections.<E>emptyList() :
> iterable;
> }
> used like this:
> for(String s : maybe(list)){
> ...
> }
>
> Me i consider a null list a bug.
>
More information about the coin-dev
mailing list