init(repeating:count:)
Creates a new string representing the given string repeated the specified number of times.
Declaration
init(repeating repeatedValue: String, count: Int)Parameters
- repeatedValue:
The string to repeat.
- count:
The number of times to repeat
repeatedValuein the resulting string.
Discussion
For example, you can use this initializer to create a string with ten "ab" strings in a row.
let s = String(repeating: "ab", count: 10)
print(s)
// Prints "abababababababababab"