Creates a new string representing the given string repeated the specified number of times.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
Parameters
repeatedValueThe string to repeat.
countThe number of times to repeat
repeatedin the resulting string.Value
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"