Proposal: for/then/else statement
deed
none at none.none
Thu Jan 3 08:57:35 PST 2013
> for(int num = 0; num < 10; num++)
> {
> if(<condition>)
> break;
> }
> then
> {
> //num successfully counted up to 10
> //do stuff...
> }
> else
> {
> //loop was broken prematurely
> //do other stuff...
> }
How about using scope inside the loop?
for (int num = 0; num < 10; num++)
{
// do stuff...
if (<condition>)
break;
scope(loop_break)
{
// loop was broken prematurely
// do other stuff...
}
scope(loop_finish)
{
// num successfully counted up to 10
// do stuff...
}
}
More information about the Digitalmars-d
mailing list