Appends the given string to this string.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
mutating func append(_ other: String)
Parameters
other
Another string.
Discussion
The following example builds a customized greeting by using the append(_:)
method:
var greeting = "Hello, "
if let name = getUserName() {
greeting.append(name)
} else {
greeting.append("friend")
}
print(greeting)
// Prints "Hello, friend"