![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
Personally, I don't like the labelled break of Java: on a quick look (if you know other languages) it looks too much like a goto to the start of the loop. For that reason, I'd be more inclined to use the boolean value (or some other condition variable) to back out of the loop. But my objection is stylistic; the labelled break works as intended. |
|
|
|
|
|
|
#12 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
I don't know whether it's good practice or not, but I always try not to put myself in situations where I would have to double-break out of loops. Now that I see this break/label statement, it makes me want to use it.
If I understand what you're trying to do, I'd use a boolean. Here is another way you could do it, but it's not as clean or efficient. I just like to think about these things. int n, x, y;
for ( n = 0; n < 100; n++ )
{
if ( array[n/10][n%10] ) break;
}
x = n/10;
y = n%10;90% of the time you can get around it pretty cleanly. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|