Start learning free

LESSON 105 OF 677 · ARRAYS I

Updating static array elements in Scala

Lesson

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

val ourArray = Array(50, 40, 30)
ourArray(0) = 15
ourArray(1) = -1

// ourArray is now Array(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