0% found this document useful (0 votes)
10 views

pro-swift-toc

The document is a comprehensive guide covering various programming concepts, including pattern matching, syntax, types, references and values, functions and closures, errors, functional programming, object-oriented programming, and protocol-oriented programming. Each section delves into specific topics with detailed explanations and examples. The guide serves as a resource for understanding and applying these programming principles effectively.

Uploaded by

SherifKamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

pro-swift-toc

The document is a comprehensive guide covering various programming concepts, including pattern matching, syntax, types, references and values, functions and closures, errors, functional programming, object-oriented programming, and protocol-oriented programming. Each section delves into specific topics with detailed explanations and examples. The guide serves as a resource for understanding and applying these programming principles effectively.

Uploaded by

SherifKamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Contents

Preface 6
Welcome

Pattern Matching 11
Matching tuples
Matching loops
Matching optionals
Matching ranges
Matching enums and associated values
Matching types
Using the where keyword

Syntax 33
If and switch expressions
Guard
Nil coalescing
Lazy loading
Lazy singletons
Lazy sequences
Destructuring
Labeled statements
Nested types
Nested functions
Documentation markup

Types 79
Useful initializers
Strings
Enums
Arrays
Dictionaries
Sets
Tuples
Ranges and RangeSet
Generics
Key paths

www.hackingwithswift.com 3
References and Values 136
What’s the difference between structs and classes?
Why use structs?
Why use classes?
Immutability in structs and classes
Closures are reference types
Mixing classes and structs

Functions and Closures 155


Variadic functions
Operator overloading
Adding a new operator
Closures: the basics
Closure capturing
Closure shorthand syntax
Closures, operators, and functions
Escaping closures
@autoclosure

Errors 191
Error fundamentals
Error propagation
Throwing functions as parameters
Typed throws
try vs try? vs try!
Assertions and preconditions
Never and fatalError()

Functional Programming 217


What is functional programming?
map()
compactMap()
atMap()
lter()
reduce()
sort()
Key path expressions as functions
Function composition
Lazy functions
Functors and monads

4 www.hackingwithswift.com
fi
fl
Object-oriented Programming 266
Object-oriented programming
Encapsulation
Inheritance
Super methods
Polymorphism
Final classes
Static properties and methods
is-a vs has-a

Protocol-oriented Programming 287


Protocol-oriented programming
Protocol extensions in detail
Thinking horizontally
POP in practice
Constrained extensions
Example extensions

Afterword 316

www.hackingwithswift.com 5

You might also like