Creates a collection containing the specified number of the given element.
The following example creates a Repeated<Int> collection containing five
zeroes:
letzeroes= repeatElement(0, count: 5)
forxinzeroes{
print(x)
}
// 0
// 0
// 0
// 0
// 0
Parameters:element: The element to repeat.
count: The number of times to repeat element.
Returns: A collection that contains count elements that are all
element.
Creates a collection containing the specified number of the given element.
The following example creates a
Repeated<Int>
collection containing five zeroes:Parameters: element: The element to repeat. count: The number of times to repeat
element
. Returns: A collection that containscount
elements that are allelement
.Declaration
func
repeatElement
<
T
>
(
_
element
:
T
,
count
n
:
Int
) -
>
Repeated
<
T
>