![]() ![]() ![]() That creates an array of filename strings, then loops over each one and checks to make sure it has the suffix “.jpg” – that it’s a picture. This is commonly used near the start of loops, where you eliminate loop variables that don’t pass a test of your choosing. If you call continue inside that loop body, Swift will immediately stop executing the current loop iteration and jump to the next item in the loop, where it will carry on as normal. When you’re looping over an array of data, Swift will take out one item from the array and execute the loop body using it. Let’s look at them individually, starting with continue. Like while loops these are sometimes used, but in practice much less than you might think. Swift gives us two ways to skip one or more items in a loop: continue skips the current loop iteration, and break skips all remaining iterations. ![]()
0 Comments
Leave a Reply. |