Break/Continue Structure
Rory Starkweather
starkweatherr at mchsi.com
Thu Mar 23 15:51:09 PST 2006
I guess I would like to ask why I shouldn't do this at the same time I
ask how to do it.
I've been looking at a piece of code like:
foreach (int i, dchar c; theString)
{
if (c == searchChar)
return i + 1;
}
return 0;
}
I understand the reason for doing this, but prefer to do things like this:
int iPointer;
iPointer = 0;
foreach (int i, dchar c; theString)
{
if (c == searchChar)
iPointer = i + 1;
// ?? break;
}
return (iPointer);
}
I realize that the extra integer takes up a little memory space, but . . .
My questions are:
Will 'break' work here?
Why not do it this way?
More information about the Digitalmars-d-learn
mailing list