Mutable versus immutable arrays

Just like the previous types you’ve read about, like String or Int, when you create an array, you must declare it as either a constant or a variable.

If the array doesn’t need to change after you’ve created it, you should make it immutable by declaring it as a constant with let. If you need to add, remove or update values in the array, then you should create a mutable array by declaring it as a variable.

results matching ""

    No results matching ""