Slice that Collection: A Swift guide
What are slices, and how are they used?
Slices make your use of collections
in Swift more efficient. This gives us an opportunity to write efficient code and really get to grips with Indices
. Shall we get started, then?
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites:
- Some knowledge of Collections in Swift
Terminology
Array: An ordered series of objects which are the same type
Collection: A sequence of elements that can be traversed (as many times as you want) and can be accessed by an indexed subscript
Enumeration: A complete, ordered listing of the items in a collection
Index: This is where files are placed that you want to commit to the git repository. Also known as the staging area.
Indices: The number position given to an Array
Integer: A number that has no fractional part, that is no digits after the decimal point
Offset: In an array or other data structure, the offset is an Integer representing the distance between the beginning of the data structure and the object in question