Programming in Swift: Fundamentals

Oct 19 2021 · Swift 5.5, iOS 15, Xcode 13

Part 2: Beginning Collections

14. Operating on Arrays

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

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

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 14. Operating on Arrays

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

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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)