Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 21st, 2006, 11:54 PM   #11
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,253
Rep Power: 5 grumpy will become famous soon enough
Quote:
Originally Posted by DaWei
I'm an acolyte looking for a high-priest to kiss my butt.
You make me very thankful I'm not a high-priest of anything. Fortunately for me, I wouldn't make a good high-priest.

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.
grumpy is offline   Reply With Quote
Old May 23rd, 2006, 4:54 AM   #12
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
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.
Harakim is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:25 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC