Created
June 10, 2020 19:22
-
-
Save iJKTen/4dac13b6cf6af7d0d588d1ed7ee36f31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1, 2, 3, 4] | |
// Another way to create an empty array of integers | |
var arr: [Int] = [] | |
// Long way to create an empty array of integers | |
var arr: Array<Int> = Array() | |
// Create a new array with a size and a default value of 0 for all the elements | |
var arr = Array(repeating: 0, count: 8) | |
arr.append(1) | |
arr.append(2) | |
// Append an array | |
arr.append(contentsOf: [3, 4, 5, 6, 7, 8]) | |
arr[0] | |
arr[1] | |
arr[2] | |
arr[3] | |
arr[4] | |
arr[5] | |
arr[6] | |
arr[7] | |
for item in arr { | |
print(item) | |
} | |
for (index, item) in arr.enumerated() { | |
print(index, item) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment