What is Array?
Array is an ordered list with indices / Index
Example of an Array can be a to do list, Shopping list, Amazon Wish List etc.
Let’s say we have an array list of apps
Index: 0 1 2 3
Element: “Reminders” “Mail” “Xcode” “Calendar”
Important Note: Index of first element is always start with zero because way computer scientist deal with data in memory they have offset & offset starts with zero & thats why array starts with zero. Index of an array never exceed the number of elements.
Here is how to declare Array in Swift: We will declare array with let or var keyword then identifier name then equal sign & then square brackets. Each elements are separated with comma.
var apps = ["Reminders", "Mail", "Xcode", "Calendar"] // Array of Strings, Each element is of Type String
var number = [1, 2, 300, 4000] // Array of Integers, Each element is of Type Integer
var bools = [true, false, false, true] // Array of Boolean values, Each element is of Type Bool
var groups = [["John", "Tom", "Steve"], ["Brandon", "Bill"]] // Array inside array
Continue reading “Chapter 04: Let’s Learn Swift Programming Language – Array in Swift” »
Continue Reading Post