Swift - Modifying Elements in an Array

Introduction

To change the value of an existing item in the array, specify the index of the item and assign a new value to it:

var OSes :[String]  = ["iOS", "Android", "Windows"]
OSes [3] = "WinPhone"

The array now contains the updated element:

You can only modify values of arrays that were declared using the var keyword.

If an array is declared using the let keyword, its values are not modifiable.

Related Topic