Can't incremen int inside funciton call -- bug?
Aldarris
aldarri_s at yahoo.com
Tue May 29 03:57:07 PDT 2007
Hello.
I have a nested function that iterates through a tree recursively.
here is it code:
void recursiveXMLTreeIteration(XMLNode currentNode, int treeLevel)
{
writefln(treeLevel);
tabOffset.length = 0;
for(int i = 0; i < treeLevel; i++)
{tabOffset ~= "\t";}
.......
foreach(XMLNode childNode; currentNode.getChildrenList())
{recursiveXMLTreeIteration(childNode, treeLevel++);}
}
recursiveXMLTreeIteration(this, 0);
Does not work as expected, in a tree of a root node plus two child nodes it prints 0,0,1.
It treeLevel++; is moved outside, works as expected:
.......
treeLevel++;
foreach(XMLNode childNode; currentNode.getChildrenList())
{recursiveXMLTreeIteration(childNode, treeLevel)
}
Prints 0,1,1,
More information about the Digitalmars-d
mailing list