Hello, welcome to the 14th tutorial for the swift basic series. And in this tutorial we are looking at the break statement. The break time allows you to exit a loop prematurely, perhaps you're in a loop, and you can have a certain condition check. If that condition is met, you just want to exit that loop. And the brainstem allows you to do that. So let's open up our project and show you how to implement the break statement.
It is really simple. So what we're just going to quickly create a an array of high scores. So we can just loop through them at 734 504 in here and zero i less than four plus, plus going to do is print ln co backslash i plus one so that just tells us what number it is colon backslash now we have printed the school. High Schools never gonna record the scores. So perhaps if the score not fair play in a country where there if the score is 34 for example, we want to break out for whatever reason so you can just do if high schools high the word equals you fall to break out you just simply put a break in it literally that simple. You can put a semicolon you don't have to put a semicolon to choice runner and look we got Scott one 100 Score 287 but because score free, the one at index two is 34 it equals that and then it breaks so if we were to go to the no 60 which isn't in the high score array, it will print out everything for you back for the four it will break out there for you won't even print there so just ended prematurely at the point of it breaking.
That's it for this tutorial. In the next tutorial, we're going to look at the continuous statement testing and basically allows you to skip any iteration of the loop. If you have any questions feel free to message us or support us on our system code. Okay, the email will be in the description you can comment on this video directly messaged us via YouTube or the recordings full source code will also be in the description. Thanks for watching and have a nice day.