February 13, 2003 for loop increment expression and if statement | ||||
---|---|---|---|---|
| ||||
Not sure if this should be legal or not.. standard says "most" statements are expressions. int main() { for (int i=0; i < 10; i++, if (i == 5) break); // Error: expression expected } A work around: for (int i=0; i < 10; i++, (i == 5) ? i = 10 : 0); Richard |
February 14, 2003 Re: for loop increment expression and if statement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard Grant | "Richard Grant" <fractal@clark.net> wrote in message news:b2h7fk$2rj8$1@digitaldaemon.com... > Not sure if this should be legal or not.. standard says "most" statements are > expressions. > > int main() { > > for (int i=0; i < 10; i++, if (i == 5) break); > // Error: expression expected > } I don't think it's legal. |
Copyright © 1999-2021 by the D Language Foundation