Beginner¶
Start here if you've never written Swift, or never finished a course. By the end you'll be running real programs from SwiftPM packages, and you'll have built a command-line app that persists data to disk.
Lessons¶
| # | Lesson | You'll learn |
|---|---|---|
| 1 | Setup & your first program | installing Swift, swift run, print, readLine, SwiftPM basics |
| 2 | Constants, variables & types | let vs var, type inference, Int Double String Bool, tuples, explicit conversion |
| 3 | Numbers & math | integer division, %, overflow traps, &+, floating point, Foundation math, random |
| 4 | Strings & characters | Unicode strings, interpolation, String.Index, Substring, raw & multi-line literals |
| 5 | Booleans & conditionals | comparisons, &&/\|\|/!, if and switch (as expressions), ranges, guard |
| 6 | Loops | for-in, ranges, stride, while, repeat-while, labels, enumerated() |
| 7 | Arrays | creating, indexing, slicing, map/filter/reduce, sorting, value semantics |
| 8 | Dictionaries & sets | key lookup, counting idiom, grouping, set algebra, Hashable |
| 9 | Functions | argument labels, defaults, tuples, variadics, inout, functions as values, recursion |
| 10 | Optionals | if let, guard let, ??, optional chaining, map, why ! is dangerous |
| 11 | Files & error handling | throws, try/catch, defer, FileManager, URL, command-line arguments |
| 12 | Capstone: task tracker | put it all together in a real CLI app |
How to work through it¶
- One lesson per sitting. Type every example. Do the exercises.
- Don't move on until the "Recap" all makes sense.
- Stuck? Re-read the "Common mistakes" section — your bug is probably there.
When you're done¶
You should be able to explain every line of the capstone and add a new feature to it unaided. Then go to Intermediate.