velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: How can I break a Foreach loop?
Date Wed, 08 Oct 2003 15:44:25 GMT
theFenix <> wrote:
> Hello:
> I'm a VM programmer and I search for a method to break a loop when I find 
an occurrence in a Vector object.
> Something like the "break" statement in Java and C++ or another way to 
simulate this.
> I hope that you can help me.

I don't think you can break it, but you can choose to ignore the rest of the 
This is all off the top of my head, so there may be syntax errors.

#set ($loopNotDone = "true")
#foreach $aValue in $aList

#if ("$loopNotDone" = "true")

## your code here

## detect end condition -- equivalent to break
#if (end condition)
#set ($loopNotDone = "false")
#end ##if (end condition)

## more of your code here

#end ## if $loopNotDone

#end ## foreach $aValue

Yeah, those years of programming in assembly can really pay off at times 
like this :-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message