Collection
extension Collection
-
Returns a random element of the Array or nil if the Array is empty.
Declaration
Swift
var sample: Element? { get } -
Returns
countrandom elements from the array. If there are not enough elements in the Array, a smaller Array is returned. Elements will not be returned twice except when there are duplicate elements in the original Array.Declaration
Swift
func sample(_ count: UInt) -> [Element]
Collection Extension Reference