Sw Course · 57 lessons · approx. 362 minutes

Learn Swift

Learn Swift in small steps: look, understand, try it out. The guided code tasks check solution patterns; a Swift compiler is not built in.

  • print
  • let & var
  • Data types
  • Strings
  • Conditions
  • Arrays
  • Loops
  • Functions
  • Optionals
  • Your own programs & going deeper
  • struct: data that belongs together
  • enum and switch
  • guard let: providing a fallback early
  • Tuples: a named pair of values
  • filter: keeping matching numbers
  • reduce: add up a list
  • A computed property
  • while: repeat as long as it is true
  • map: converting every value
  • class: an object with behaviour
  • protocol: agreeing on an ability
  • sorted with a closure: your own order
  • Texts and collections
  • Optionals and errors
  • Going deeper into types
  • Closures
  • Protocols and generics
  • Dictionaries and switch

What you’ll learn

  1. Chapter 1One line after another – Printing and storing values – no prior knowledge needed.
    Hello, Swift! · Remembering something with let · Changing values with var · What kind of value?
  2. Chapter 2Calculating and deciding – Combining values and making decisions.
    Calculating with numbers · Inserting values into text · Comparing · if and else
  3. Chapter 3Several values, reusable code – Lists, repetitions and functions.
    Arrays: a list · for: visiting every value · func: reusing code · Optionals: a value can be missing
  4. Chapter 4Workshop: understand and build it yourself – Practise new building blocks with short explanations and your own programs.
    A function returns a result · Dictionary: finding values by name · if let: using an existing value
  5. Chapter 5New tools for your own ideas – Understand new concepts, fill them in and use them yourself.
    struct: data that belongs together · enum and switch · guard let: providing a fallback early
  6. Chapter 6Level up: your next practice chapter – Understand four new building blocks in small steps and use them yourself.
    Tuples: a named pair of values · filter: keeping matching numbers · reduce: add up a list · A computed property
  7. Chapter 7Master chapter: how real programs are built – Five building blocks from real projects – explained, connected, filled in and written by you.
    while: repeat as long as it is true · map: converting every value · class: an object with behaviour · protocol: agreeing on an ability · sorted with a closure: your own order
  8. Chapter 8Texts and collections – Text methods, split and joined, sets, compactMap and a word counter.
    uppercased, hasPrefix and contains · split and joined · Set: every element only once · compactMap: sorting out nil · Boss: count words
  9. Chapter 9Optionals and errors – Fallback values with ??, optional chaining, throws, try? and errors with data.
    Fallback values with ?? · Optional chaining with ?. · Throwing errors: throws and catch · try? turns errors into nil · Boss: checking orders
  10. Chapter 10Going deeper into types – mutating, extensions, enums with values, inheritance and protocol extensions.
    mutating: changing structs · extension: extending types · enums with values attached · Inheritance with override · Boss: shapes with a protocol
  11. Chapter 11Closures – Functions as values, map/filter/reduce with $0, sorting with your own rule, trailing closures and closures with memory.
    Functions as values: closures · map, filter and reduce with $0 · Your own sort rule: sorted(by:) · Trailing closures and forEach · Boss: closures with memory
  12. Chapter 12Protocols and generics – Contracts with protocol, default behaviour via extension, generic functions, Comparable and a generic stack.
    Contracts with protocol · Default behaviour via extension · Generic functions · Making your own types comparable: Comparable · Boss: a generic stack
  13. Chapter 13Dictionaries and switch – Look up values with a default, count, switch with ranges, conditions and tuples.
    Looking things up: Dictionary · Counting words and printing them sorted · switch with ranges and where · switch over tuples · Boss: a stock with orders

Final project: Swift learning companion

A small program with a name, a score and motivating feedback.

How it works

Every lesson starts with short explanation pages. Then you practise with multiple-choice questions, fill-in-the-gap tasks, putting code in order and writing your own code – with hints and instant feedback. Free, without ads, on phone, tablet and PC.

Learn Swift now