velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Withers John Z" <John.With...@irs.gov>
Subject RE: How can I get the length of Array ?
Date Thu, 25 May 2006 12:59:12 GMT
I think $arr.size() would return the length of the array.  If memory
serves, Velocity implements arrays as ArrayList.

John Withers 

-----Original Message-----
From: trad-ex [mailto:trad-ex@inter7.jp] 
Sent: Thursday, May 25, 2006 1:13 AM
To: Velocity Users List
Subject: How can I get the length of Array ?

Hi all,

In the Velocity realm, how can I get the length of Array ?
For instance,

#set( $arr = __set int[] value__ )
#if( $arr.length > 0 )
 ...(snip)...
 
$arr.length is always null. Why ?
I always use helper Object to avoid this issue.
For example, 

$helperObj.lengthOf( $arr )

This method, lengthOf, is described below:

 public int lengthOf( Object[] objects )  {
   if( objects == null)
     return 0;
   return objects.length;
 }
 
Best Regards,
trad-ex


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message