Initializer

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 repeatedValue in the resulting string.

Discussion

For example, use this initializer to create a string with ten "00" strings in a row.

let zeroes = String(repeating: "00", count: 10)
print(zeroes)
// Prints "00000000000000000000"