A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 50 companion flashcards using spaced repetition.
An Optional in Swift is a type that can hold either a value or the absence of a value, represented by nil. It is declared by appending a question mark to the type, as in var name:...
A Protocol in Swift defines a blueprint of methods, properties, and other requirements that conforming types must implement. Classes, structs, and enums can all conform to a protoc...
A closure in Swift is a self-contained block of functionality that can be passed around and used throughout the code. Closures have a syntax that resembles a function without a nam...
Swift has two fundamental categories of types based on how they are stored and passed. Value types, which include structs, enums, and tuples, are copied when assigned or passed int...
Generics enable developers to write flexible, reusable functions and types that work with any type. Instead of duplicating logic for each type, a generic placeholder like T is used...
Swift uses a do-try-catch model for error handling that integrates well with the type system. Functions that can fail are marked with the throws keyword, and callers must explicitl...
Memory management in Swift for class instances is handled by Automatic Reference Counting, or ARC, which tracks the number of strong references to each instance and deallocates the...