A set is a sequence or collection of unique elements. These elements can never be duplicated. A range is a sequence that contains values from a lower bound and upper bound. We can initialize a set using a range in Swift.
let set = Set(range)
range: This is the range by which the set instance will be initialized.
A set is returned and initialized with values from the given
// create Set instances and initialise let set1 = Set(0..<7) // range from 0-6 let set2 = Set(10..<20) // range from 10-20 let set3 = Set(0..<0) // empty range // print Set instances print(set1) print(set2) print(set3)
Setinstances and initialize them with some range sequences.
View all Courses