Round 2 feedback

Michael Nascimento misterm at
Wed Feb 13 07:46:39 PST 2013

On Wed, Feb 13, 2013 at 1:37 PM, Brian Goetz <brian.goetz at> wrote:
> It previously was called mappingTo.

Hmm, I still wouldn't be able to tell what it does, but I would take a
look at the signature and the Javadoc, so I guess it is better.

> So, a static method:
>   static<K,V> V getOrElse(Map<K,V> m, K k, V alt) {
>     return map.containsKey(k) ? map.get(k) : alt;
>   }
> will do what you want in the meantime?
> -> getOrElse(totalByCity, city, 0));

Sure it would, but I would expect Map to have such a method now :-)
Returning an Optional makes it more generic though, I only migrated
part of the application so far, so it might be useful even in my code

> (The unordered is not adding any value here.)

Even if the implementation is a LinkedHashSet?


More information about the lambda-dev mailing list