Start learning free

LESSON 106 OF 678 · ARRAYS I

Arrays in Swift

Lesson

The entries of Arrays are mutable and can be changed freely, using indices and subscript notation:

Assigning to array[index] replaces the element placed at that index with the new value:

var numbers = [50, 40, 30]

numbers[0] = 15
numbers[2] = -1

// numbers is now [15, 40, -1]

Assignment
Follow the Coding Tutorial and let's play with some arrays.


Hint
Look at the examples above if you get stuck.


STEP 1 OF 2
    Ctrl + Enter to check