#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    12 year noob is very confused


    hi my parents said if I can learn computer langages before summer i can go to computer camp which i would love to do but I am having trouble understanding couple of things. i am teaching myself and going through tutorials and sites but something are easy to understand and some are just confusing.

    i learned a while loop and i understand the loop but it said i could nest a if statement in there which I did but it also said i could use a continue statment thats where i got confused. i got the break statment and how to use it, but the continue statment (i dont know if that is even a statment) does it just continue with the loop?

    Can someone please just give me a simple explanation
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    2
    WRONG INFO GIVEN. ABORTING ^^
    Last edited by notflip; November 7th, 2012 at 01:39 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    10
    Rep Power
    0
    Break ends the loop, continue finishes that iteration of the loop (it sends you back to the top of the code in the loop).
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,872
    Rep Power
    6351
    Rukbat is right, notflip is wrong. The example notflip gave was the PHP.net example of what NOT to do with the "continue" command, and illustrates an unexpected behavior if you forget to put a semicolon at the end of the line. Notflip's example is also invalid PHP code since he used echo instead of print, which is a very important distinction in this example and basically nowhere else.

    continue; is a statement which forces the loop to move on to the next item in the loop. In notflip's example, if it were syntactically correct and there was a semicolon after the continue, would print 0, 1, 3, 4. That's because the loop reaches the "continue" point at element 2 and never finishes execution.
    Last edited by ManiacDan; November 6th, 2012 at 11:46 PM.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    38
    Rep Power
    2
    Originally Posted by ManiacDan
    Rukbat is right, notflip is wrong. The example notflip gave was the PHP.net example of what NOT to do with the "continue" command, and illustrates an unexpected behavior if you forget to put a semicolon at the end of the line. Notflip's example is also invalid PHP code since he used echo instead of print, which is a very important distinction in this example and basically nowhere else.

    continue; is a statement which forces the loop to move on to the next item in the loop. In notflip's example, if it were syntactically correct and there was a semicolon after the continue, would print 0, 1, 3, 4. That's because the loop reaches the "continue" point at element 2 and never finishes execution.
    This is correct. You can use IF inside a LOOP and then use the continue statement to continue with the iteration without doing anything in that specific iteration, or just break to stop iterating the values that are left. Hope you can go to the camp.

    Regards.

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo