do-while loops

Manfred Nowak svv1999 at hotmail.com
Wed Dec 28 13:45:49 PST 2011


bearophile wrote:

> void main() {
>     do {
>         int x = 5;
>     } while (x != 5); // Error: undefined identifier x
> }
> 

Do you mean, that the similar while-loop should also be okay?

| void main() {
|     while (x != 5) /* uses `x' out of _following_ scope */ { 
|         int x = 5;
|     };
| }

-manfred


More information about the Digitalmars-d-learn mailing list