Sobes.tech
Junior — Senior

What is the output of program №9

livecode

Task condition

This task involves a small snippet of Swift code. It creates a set of strings, to which several names are added sequentially, some of which are repeated. After all insertions, the number of elements in the set is printed. The question is to determine what number will be printed.

import UIKit

var uniqueNames = Set<String>()
uniqueNames.insert("Boris")
uniqueNames.insert("Andrey")
uniqueNames.insert("Boris")
uniqueNames.insert("Arthur")
uniqueNames.insert("Boris")

print(uniqueNames.count)