Creates a string representing the given character repeated the specified number of times.
SDK
- Xcode 10.0+
Framework
- Swift Standard Library
Declaration
Parameters
repeatedValueThe character to repeat.
countThe number of times to repeat
repeatedin the resulting string.Value
Discussion
For example, use this initializer to create a string with ten "0" characters in a row.
let zeroes = String(repeating: "0" as Character, count: 10)
print(zeroes)
// Prints "0000000000"