Quantcast
Channel: ZDoom
Viewing all articles
Browse latest Browse all 3391

Bugs [GZDoom] • foreach loop syntax?

$
0
0
Hi all. I'm having trouble getting "foreach" loops to work:

Test code:

Code:

44    override void Tick() {45        array<String> testStrings;4647        testStrings.append("A");48        testStrings.append("B");49        testStrings.append("C");5051        foreach (item : testStrings) {52            console.printf("This string: %s", item);53        }5455        Super.Tick();56    }
Error message:
...
LoadActors: Load actor definitions.
Script error, "<file.zs>" line 51:
Unexpected '{'
Expecting ';'
Example provided on ZDoom.org wiki:

Code:

Array<Actor> things;foreach (mo : things){  if (mo)  {    // Do something  }}
And as additional information, if in my code example above I delete the curly braces forming the foreach loop block, the error message becomes:
...
LoadActors: Load actor definitions.
Script error, "<file>.zs" line 52:
Unexpected identifier
Expecting ';'

Statistics: Posted by D2JK — Tue Jul 30, 2024 12:53 pm



Viewing all articles
Browse latest Browse all 3391

Trending Articles