Sets

Create a set
var letters = Set<Characters>()

Insert a character
letters.insert("a")

Initialise a set
var setStrs: Set<String> = ["abc", "def"]
//If you were to add another "abc", it will not be added or it will override the other "abc".


Get count
print(setStrs.count)


Notes:
- Another form of collections
- No defined ordering, need to ensure that a number only appears once.

Comments

Popular posts from this blog

Setting up a playground

Go to another page