Initializer

init(repeating:count:)

Creates a new collection containing the specified number of a single, repeated value. 指定された数の、ある単一の値の繰り返しを含んでいる新しいコレクションを作成します。

Declaration 宣言

init(repeating repeatedValue: Character, count: Int)

Parameters パラメータ

repeatedValue

The element to repeat. 繰り返される要素。

count

The number of times to repeat the value passed in the repeating parameter. count must be zero or greater. repeatingパラメータで渡された値を繰り返す回数。countは、ゼロまたはより大きくなければなりません。

Discussion 議論

Here’s an example of creating an array initialized with five strings containing the letter Z. ここに、字Zを含んでいる5つの文字列で初期化される配列を作成する例があります。


let fiveZs = Array(repeating: "Z", count: 5)
print(fiveZs)
// Prints "["Z", "Z", "Z", "Z", "Z"]"