Start learning free

LESSON 92 OF 349 · ARRAYS I

Updating static array elements in Swift in Swift

Lesson

Unlike strings, the entries of arrays are mutable and can be changed freely, using indices and the bracket notation:

var ourArray = [50, 40, 30]
ourArray[0] = 15
ourArray[1] = -1

// ourArray is now [15, -1, 30]

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

    Updating Static Array Elements in Swift

    Keep going with SwiftAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free