Swift: Replace String array at index

Swift

Swift Problem Overview


I have the following String Array:

var stringArray:[String] = ["value1", "value2", "value3", "value4"]

how can I replace for example the third String with index 2 ("value 3") with another string?

Swift Solutions


Solution 1 - Swift

Simple as that:

stringArray[2] = "new string"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3143691View Question on Stackoverflow
Solution 1 - SwiftAdamView Answer on Stackoverflow