As of Swift 1.2, Apple introduces Set collection type.
Set
Say, I have a set like:
var set = Set(arrayLiteral: 1, 2, 3, 4, 5)
Starting with Swift 4.2, you can use randomElement:
let random = set.randomElement()