Swift by Sundell cover image

80: “Lists and loops”, with special guest Nick Lockwood

Swift by Sundell

CHAPTER

Swift Foot Gun

Swift's type system is based on the idea of copy on right. Value types have to be fixed size and arrays and strings generally aren't in Swift because they're mutable. So all mutations of that underlying array happen through the struct, which is wrapping the pointer. And again, this is great for performance in one sense, because it means that you're not copying that entire heap object every time you make a new copy of the array. But then you run into this weird edge case where it's the reason why your app is running slow.

00:00
Transcript
Play full episode

Remember Everything You Learn from Podcasts

Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.
App store bannerPlay store banner