Unit 01 of 03
Language Basics
Swift's design goals, constants and variables, type inference, basic types, the string and character model, operators, control flow with pattern-matching switch, functions with argument labels, and closures with capture lists.
Published Updated
Lessons
- 01 Swift's Design Goals Ties Swift's three goals — safety, expressiveness, performance — to one measurement axis: when is this expression evaluated? Splits eight expressions into four moments. 13 min read
- 02 Constants and Variables Measures `let` and `var` together with type inference, explicit type annotation and the moment of assignment: is a constant evaluated immediately, and is an assignment evaluated every time? 13 min read
- 03 Basic Types Introduces the `Int`, `Double`, `Bool` and `String` types; measures that conversion is explicit and that a conversion expression is evaluated immediately. 13 min read
- 04 String Operations Measures the character and byte counts of a `String` value, indexing and interpolation: an interpolated expression is rebuilt on every use. 14 min read
- 05 Operators Introduces arithmetic, comparison and range operators; measures that the right-hand side of `||`, `&&` and the ternary operator may never be evaluated. 10 min read
- 06 Control Flow Introduces conditions, loops and the pattern-matching `switch` statement; measures that `where` conditions after the first match are never evaluated. 12 min read
- 07 Functions Introduces argument labels, default values, multiple returns through a tuple and the `inout` parameter; measures that a default argument expression is evaluated on every call. 13 min read
- 08 Closures Introduces closure syntax, the `$0` shorthand, the trailing closure and the `sorted(by:)` call; measures that a capture list is evaluated once, when the closure is created. 13 min read