jastrachan | 5 Apr 08:59 2004
Picon

Re: array length

FWIW in Groovy there's a polymorphic way to get the size of anything, 
be it an array, collection, String etc. its the 'size()' method.

s1 = new Object[] { 1, 2, 3 }.size()
s2 = "hello".size()
s3 = [1, 2, 3, 4].size()

On 2 Apr 2004, at 17:57, bing ran wrote:

> I'm not sure if this is an know issue/issues:
>
>
> Object[] ss = new Object[] {'hello'}
> Object[] is = new Object[] {new Integer(1)}
>
> println ss.length		// this returns a MethodClosure instead
> of 1
> println is.length		// runtime error: no such property
> length on Integer
>
>
> "length" should simply return the length of the array. The first case
> treats length as a MethodClosure and the second as a property (the
> property thing hit back again:))
>
>
> Surprise...
>
>
> bing
>
> _______________________________________________
> groovy-user mailing list
> groovy-user@...
> http://lists.codehaus.org/mailman/listinfo/groovy-user
>
>

James
-------
http://radio.weblogs.com/0112098/

Gmane