12 Sep
2007
12 Sep
'07
7:47 a.m.
On 9/11/07, Richard Warburton <richard.warburton@gmail.com> wrote:
In java we could get a similarly concise effect, with no hacking in syntactic sugar to solve these problems, I am thinking of a syntax along the lines of:
List<Integer> intList = new ArrayList<Integer>(1,2,3);
Most welcome! The one-liner I use is new ArrayList(Arrays.asList(1,2,3)); but it goes on my nerves. On a side note, I would be interested in the history of var-args in this context - in the tiger release we were given var-args and at the same time shunned away from arrays. Was List considered for varargs? Nowadays I code many methods twice: void f(X...x) { f(Arrays.asList(x)); } void f(List<X> x) { ... }