Swift Strings: Concatenation
Swift Strings: Concatenation
Join strings with +, or use interpolation to insert values into a string.
Concatenate vs Interpolate
Use + to make a new string. Use interpolation to insert values inline.
Example
let first = "Hello"
let second = "Swift"
// Concatenation
print(first + " " + second)
// Interpolation
print("\(first), \(second)!")
Interpolation is often clearer when mixing text and values.
Append Strings
Use += to append to a mutable string.