Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1098287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:33:27+00:00 2026-05-17T00:33:27+00:00

Recently we found a good way to comment out lines of code by using

  • 0

Recently we found a “good way” to comment out lines of code by using continue:

for(int i=0; i<MAX_NUM; i++){
  ....
  .... //--> about 30 lines of code
  continue;
  ....//--> there is about 30 lines of code after continue
  ....
}

I scratch my head by asking why the previous developer put the continue keyword inside the intensive loop. Most probably is he/she feel it’s easier to put a “continue” keyword instead of removing all the unwanted code…

It trigger me another question, by looking at below scenario:

Scenario A:

for(int i=0; i<MAX_NUM; i++){
  ....
  if(bFlag)
    continue;
  ....//--> there is about 100 lines of code after continue
  ....
}

Scenario B:

for(int i=0; i<MAX_NUM; i++){
  ....
  if(!bFlag){
  ....//--> there is about 100 lines of code after continue
  ....
  }
}

Which do you think is the best? Why?
How about break keyword?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:33:28+00:00Added an answer on May 17, 2026 at 12:33 am

    Using continue in this case reduces nesting greatly and often makes code more readable.

    For example:

    for(...) {
        if( condition1 ) {
            Object* pointer = getObject();
            if( pointer != 0 ) {
                ObjectProperty* property = pointer->GetProperty();
                if( property != 0 ) {
            ///blahblahblah...
            }
         }
    }
    

    becomes just

    for(...) {
        if( !condition1 ) {
            continue;
        }
        Object* pointer = getObject();
        if( pointer == 0 ) {
            continue;
        }
        ObjectProperty* property = pointer->GetProperty();
        if( property == 0 ) {
           continue;
        }
    
        ///blahblahblah...
    }
    

    You see – code becomes linear instead of nested.

    You might also find answers to this closely related question helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WebSockets? I just recently ran across websockets and have heard some good things about
I have recently been doing a security code review for my company and using
Our project is an Eclipse RCP application using Hibernate as an ORM. I recently
I have recently found the power of setting variables to a block in the
I recently wanted use regex in Cocoa app. But I found that Cocoa does
I have recently put together a JWS application which gets it's argument from a
I recently installed Redmine and started configuring a plethora of items such as roles,
Recently I've been working on a WCF app and needs some functionalities to compress
I have recently begun to develop a game in Haxe which targets the Flash
I'll start by saying that I'm fairly new to the idea of deploying applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.