top of page

Let's start with a for loop in Swift!

A for loop can be used when there is a need to iterate through a list of items or sequence and execute set of instructions for each item or sequence.

I will try to divide this post in series of questions and answers.

How to write a for loop in Swift to run 100 times?

Alternate way to write the same

First way is called closed range - range with 3 dots. Includes both starting number and end number. Result of the loop will be 100 itineration with value of 'i' ranging from 0 to 99.

Second way is half-closed range - Includes start number but not the last number. Result of the loop will be same as first one - 100 itineration with value of 'i' ranging from 0 to 99.

Featured Posts
Recent Posts
Archive
Search By Tags
No tags yet.
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page