Swift Fundamentals: Arrays and Sets

preview_player
Показать описание
In the previous episode, we explored some of the common types defined by the Swift standard library. Today, we continue that exploration by taking a close look at collection types. The Swift standard library defines three collection types, arrays, sets, and dictionaries. This episode zooms in on arrays and sets.

While each collection type has a unique set of features, the collection types of Swift's standard library also have a few things in common. The values and keys stored by arrays, sets, and dictionaries are strictly typed. In other words, you cannot insert an integer into an array of strings.

This may seem like a major limitation if you're used to working with weakly typed languages. The benefits, however, far outweigh this limitation. You always know what to expect when you're working with a collection in Swift. That's a significant benefit if your goal is creating a robust codebase.

Рекомендации по теме
Комментарии
Автор

Awesome video as usual. Is it possible to make a custom Class have union or intersection methods implemented from Set? I can see how it could be really useful to be able to do things like: me.instersection(friend) where `me` and `friend`are instances of a 'Friend' class for example, and it returns friends in common.

jlecampana