logo       

RE: standard for loop: msg#00194

lang.groovy.user

Subject: RE: standard for loop

You can do something cheeky like:

for (i in 0...foo.size()) { println i }

Dion

-----Original Message-----
From: Scott Stirling [mailto:scottstirling-KealBaEQdz4@xxxxxxxxxxxxxxxx]
Sent: Monday, November 29, 2004 11:17 PM
To: groovy user
Subject: [groovy-user] standard for loop

Hi,

Is there a Groovy idiom (with a counter) to use instead of a standard 'for'
loop? I need to use the counter from the loop iterations.

I get this exception when I code a standard 'for' loop (i.e., for (int i =0;
i < foo.size(); i++):

Exception in thread "main" NOT YET IMPLEMENTED: standard for loop
at
org.codehaus.groovy.syntax.parser.ASTBuilder.forStatement(ASTBuilder.jav
a:1026)
at
org.codehaus.groovy.syntax.parser.ASTBuilder.statement(ASTBuilder.java:
773)
at
org.codehaus.groovy.syntax.parser.ASTBuilder.topLevelStatement(ASTBuilde
r.java:327)
at
org.codehaus.groovy.syntax.parser.ASTBuilder.build(ASTBuilder.java:198)
at
org.codehaus.groovy.control.SourceUnit.convert(SourceUnit.java:339)

Thank you,
Scott Stirling
Framingham, MA






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise