Start learning free

LESSON 91 OF 349 · ARRAYS I

Accessing Array elements in Swift in Swift

Lesson

We can access the data inside an Array using indexes.

Arrays also use zero-based indexing, so the first element in an Array has an index of 0.

var array = [50, 60, 70]

print(array[0]) // Output: 50

let data = array[1]
print(data) // Output: 60

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 3
    Ctrl + Enter to check

    Accessing 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