23 Feb 2005 20:59
Re: support of Java style arrays; or using Groovy arrays?
On 23 Feb 2005, at 19:57, Guillaume Laforge wrote: > On Wed, 23 Feb 2005 19:35:54 +0000, jastrachan@... > <jastrachan@...> wrote: >> In general yes - but I think arrays and lists could be an obvious >> exception >> >> int[] x = [1, 2, 3] >> >> seems reasonable. e.g. Java allows >> >> int[] x = {1, 2, 3} >> >> so I think the explicit coercion for lists & arrays in static type >> mode >> seems a little noisy. > > In static type mode, yes, I quite like that notation too: > > int[] x = [1, 2, 3] > > creates an array of ints. > > But for dynamic typing, the explicit coercion is needed: > > def x = [1, 2, 3] as int[] > > Otherwise, > > def x = [1, 2, 3] > > would create a list, not an array. Absolutely! James ------- http://radio.weblogs.com/0112098/
RSS Feed