The Array in Swift
Where, and how does the Swift compiler store values in an array?
Although this is a rather basic function within the Swift language it can be quite difficult to conceptually think about what is actually happening in your machine.
Now since memory locations are used, you should be aware that the locations chosen by your machine at any given moment in time. Please note that also some liberties have been taken here with the abstractions used to explain arrays and the memory locations in Swift, but I hope these can be forgiven for the brevity and clarity that their use gives in the following article.
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites:
- Be aware of the theory behind variables (guide HERE)
Terminology
Array: An ordered series of objects which are the same type
ContiguousArray: A specialised array that always uses contiguous memory
Contiguous memory: Memory that has been assigned consecutive memory blocks (physically)