Programming in Swift: Fundamentals

Oct 19 2021 Swift 5.5, iOS 15, Xcode 13

Part 2: Beginning Collections

14. Operating on Arrays

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 13. Arrays Next episode: 15. Challenge: Arrays

Update Notes: The student materials have been reviewed and are updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

So you’ve learned how to create arrays, and how to append elements to them, using the append method and the += operator.

pastries[0]
pastries[13]
let firstThree = pastries[1...3]
firstThree[0]
let firstThree = Array(pastries[1...3])
firstThree[0]
pastries.append("eclair")
pastries.removeAll()
pastries.isEmpty
pastries.count
pastries.first
if let first = pastries.first {
  print(first)
}
pastries.contains("donut")
pastries.contains("lasagna")
pastries.insert("tart", at: 0)
let removedTwo = pastries.remove(at: 2)
let removedLast = pastries.removeLast()
removedTwo
removedLast
pastries
pastries[0...1] = ["brownie", "fritter", "tart"]
pastries
pastries.swapAt(1, 2)