by mmahemoff · 15y ago · 0 comments
I find it breathtaking this isn't core yet. I was writing test fixture support code for 1.4 to easily and DRYly generate lists of up to 10 items, which required 10 copy-paste functions each with a different number of arguments. 1.5 came along and made it possible to easily do it with one function thanks to varargs, but it's 6 years later and still no collection literals!
List<String> people = ImmutableList.of("Frank", "Mary", "Bob");
There's also ImmutableSet and many other goodies, to say the least. For instantiation of these generic types, you can do: List<String> people = Lists.newArrayList();
Map<String,Integer> scores = Maps.newHashMap();
and so on. List<String> people = Arrays.asList("Frank", "Mary", "Bob");
[1] http://download.oracle.com/javase/1.5.0/docs/api/java/util/A...It is like the Java world hit the 'pause' button on really ambitious stuff for a few years and the only things that got into releases were the laser-sharp-focused features that the teams needed no variation on. They knew exactly what the feature was, where to take it and when to ship it.
I think it was for the better, because now there is all this pent up energy getting reinjected into the platform and we'll see 8 next year with the rest of all these goodies and hopefully 9/10 2 years after that.
Pretty good recovery IMO. At least it didn't languish and die a horrible death or something.
I think adding special syntax rules is a pretty bad idea.