[The Java Posse] Re: {{}} (#338)

2011-02-04 Thread Christian Catchpole
But this still isn't as bad as those "returning self" stacked builder methods. :) #flamewarbeginsnow -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to javaposse@googlegroups.com. To unsubscribe from this gro

Re: [The Java Posse] Re: {{}} (#338)

2011-02-04 Thread Mark Derricutt
More than MapMaker, I'd recommend Guava's ImmutableMap.of(key,value,key,value..); -- "Great artists are extremely selfish and arrogant things" — Steven Wilson, Porcupine Tree On Fri, Feb 4, 2011 at 9:43 PM, Reinier Zwitserloot wrote: > (B) There are better alternatives. Namely, Guava's MapM

[The Java Posse] Re: {{}} (#338)

2011-02-04 Thread Reinier Zwitserloot
As others have hinted at in this thread, Double-bracket map initialization is a bug. If I see it in any code checked into projects, it gets rejected. There's the somewhat nebulous (as in, YMMV) issue of it being not particularly readable, simply because many java programmers don't recognize the

[The Java Posse] Re: {{}} (#338)

2011-02-03 Thread Christian Catchpole
This thing that bugs me about this approach is that you are defining a sub-class for the sake of making "neater" code. You don't actually want a subclass, but it's a side effect of the approach. And being a subclass it can cause further problems. I'm happy to take coding shortcuts but I'd put th

[The Java Posse] Re: {{}} (#338)

2011-02-03 Thread Tom Hawtin
On Feb 3, 4:55 pm, jwd wrote: > This instance initializer syntax seems to get rediscovered every year > or so.  The first identification as a Java idiom that I was aware of > was Paul Holser'shttp://www.pholser.com/writings/concisions.htmlFWIW > the language specification for this can be found >

[The Java Posse] Re: {{}} (#338)

2011-02-03 Thread jwd
This instance initializer syntax seems to get rediscovered every year or so. The first identification as a Java idiom that I was aware of was Paul Holser's http://www.pholser.com/writings/concisions.html FWIW the language specification for this can be found in http://java.sun.com/docs/books/jls/th

[The Java Posse] Re: {{}} (#338)

2011-02-02 Thread Eric Jablow
On Feb 2, 11:37 am, Alexey Zinger wrote: > public Map getAges() > { >     return new HashMap() >     {{ >         put("kitty", 7); >         put("puppy", 2); >         put("fishy", 3); >     }} > > } > > What it really is is an anonymous inner class that extends HashMap and has an > instance ini