Initializer

init(_:)

Creates a new string from the given substring.

Declaration

init(_ substring: Substring)

Parameters

substring

A substring to convert to a standalone String instance.

Discussion

Complexity: O(n), where n is the length of substring.

See Also

Creating a String

init()

Creates an empty string.

init(Character)

Creates a string containing the given character.

init<S>(S)

Creates a new string containing the characters in the given sequence.

init<S>(S)

Creates a new instance of a collection containing the elements of a sequence.

init<S>(S)

Creates a new string containing the characters in the given sequence.

init(repeating: String, count: Int)

Creates a new string representing the given string repeated the specified number of times.

init(repeating: Character, count: Int)

Creates a string representing the given character repeated the specified number of times.