Eigenpoll : D wish list : Foreach on first/on last
To enable the coder to specify code statements that are only executed on the first and on the last iterations of a loop.
foreach( ; )
on first // First iteration only
on last // Final iteration only
Example:
foreach( CustRec c; CustomerList )
{
on first {
Lineno = 0;
Totals = 0;
Pageno = 0;
InitializeReport();
}
Lineno++;
GenPageHeading(Lineno, Pageno);
GenDetailLine(Lineno, c, Totals);
on last {
GenFooter(Totals);
CloseReport();
}
}
This is independant of the proposed 'else' clause.
Report this item for cleanup