Home

lovelejess

21 Aug 2018

swift4: deeper dive- loops

Currently enrolled in Udemy’s- The Complete iOS 11 & Swift Developer Course Notes from Lesson 4

While Loops

  • use while loops when you want the same lines of code executed when the boolean condition is satisifed
  • syntax:
          while (true) {
              //do something here
          }
    

For Loops

  • used to loop over collections
  • traditional syntax:
          for item in collection {
              //do something here
          }
    
  • enumerating syntax:
      for (index, value) in numbers.enumerated() {
          numbers[index]+= value+=1
      }
    

Til next time,
lovelejess at 14:32

scribble