Continue Statement

2 minutes
Share the link to this page
Copied
  Completed
Learn about how the continue statement can be used to progress through the code.

Transcript

Hello, welcome to the 15th tutorial in the swift basic series and this part we're going to look at the continue statement, continuous statement, they need to skip any iteration inside the loop. So if we have five iterations inside for loop for that bond, we do the continue statement, we'll skip that particular iteration and one read the code that is afterwards in that loop. So let's just show you how to implement it. It is extremely simple. Accidentally added a breakpoint. Let's get rid of that.

So what we're going to do is a turnover rate that we're going to be looking for equals 187 34, five and they're so full, quickly set up this for loop i equals zero is less than five. I plus plus got pregnant and then that's cool. backslash i plus one, colon backslash. I suppose I, now if we just run this we've got all the scores printed out, what we can do is if one of the scores equal 34, which one of them does, it is differed on the one at index two, then we're going to continue cuz we some reason we don't want to run any more code in this particular iteration. And we just continue and put a semicolon or you don't have to, it's your choice. We're just going to write and as you can see, we've got score one score to go for let's go fiber score free missing, readiness missing.

It's because we did this check That check is the current high score in this particular iteration of the loop. 34. Nope, nope. Yes. So then went into this little piece of code did continue. So it skips all of this starts the next iteration all over again.

So then again, check again to five equal 34. Now it doesn't say print a score at zero 34. No, it doesn't even print as well. So yeah, that's it for the continue statement. In the next tutorial, we're gonna look at function that helps implement them using Swift. If you have any questions, feel free to message us at support at sonar system, Koto, UK, the email will be in the description.

You can comment on this video directly messages via YouTube. All the required links or source code will also be in the description and as usual, thanks for watching and have a nice day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.