randomSample(count:)

Randomly selects the specified number of elements from this sequence.

RandomSample.swift:260
func randomSample(count k: Int) -> [Element]

Parameters

k

The number of elements to randomly select.

Returns

An array of k random elements. The returned elements may be in any order. If k is greater than this sequence’s count, then this method returns the full sequence.

This method is equivalent to calling randomSample(k:using:), passing in the system’s default random generator.