Tsallaka zuwa abun ciki
Justice Tech School

Sets

Set stores unique values with fast membership. Use union, intersection and subtracting.

Example
let a: Set = [1, 2, 3]
let b: Set = [3, 4]
print(a.union(b).sorted())
print(a.intersection(b))
print(a.subtracting(b).sorted())
print(a.contains(2))

Exercise

Common items.

a.(b)

Quiz Test

Do sets keep duplicates?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.