velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dimitrios Kolovos" <dskolo...@hotmail.com>
Subject Remove last comma...
Date Fri, 14 Jan 2005 10:17:51 GMT
Hi all,

When iterating a collection/array it is usual that you add something after 
each iteration except for the last.

e.g.

#foreach ($i in [1..10])$i,#end

produces

1,2,3..10,

The only way I know in which I can omit the last comma is to use 
velocityount. Nevertheless, I think it would be more elegant if there was a 
variable (e.g. $output) in the context that represented the so far produced 
text. Then I could call a method like $output.chop(n) and chop the last n 
characters.

Any thoughts?

Dimitrios Kolovos 

---------------------------------------------------------------------
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