The first
property of a set in Swift returns the first element of the set. Note that this first element is not necessarily the element that was added first to the set. We should not expect any particular ordering of a set in Swift.
set.first
The value returned is an element of the set that is accepted as the first.
// create some setslet evenNumbers : Set = [10, 2, 6, 8, 4]let oddNumbers : Set = [11, 5, 7, 3, 9]let first_names : Set = ["john", "jane", "henry", "mark"]// get the first elements of the setsprint(evenNumbers.first!)print(oddNumbers.first!)print(first_names.first!)
first
property to get the first element of the sets. We then print the results to the console.