Instance Method

append(_:)

Appends the given character to the string.

Declaration

iOS, macOS, tvOS, watchOS
mutating func append(_ newElement: Character)

Parameters

c

The character to append to the string.

Discussion

The following example adds an emoji globe to the end of a string.

var globe = "Globe "
globe.append("🌍")
print(globe)
// Prints "Globe 🌍"

Relationships

See Also

Appending Strings and Characters

func append(String)

Appends the given string to this string.

func append<S>(contentsOf: S)

Appends the characters in the given sequence to the string.

func append<S>(contentsOf: S)

Adds the elements of a sequence or collection to the end of this collection.

func reserveCapacity(Int)

Reserves enough space in the string’s underlying storage to store the specified number of ASCII characters.