A Swift Tour(Review of Basic Syntax)

  1. ?? operator: returns the default value which is after ??, if the optional value before ?? is nil.

2. switch: we can specify a certain case like let x where …

3. Writing Closures Concisely

  • closure? : a block of code that can be called later
  • in Swift, a function is a special case of closures

4. Class Structure

Every variable in a class must be initialized either directly or by the init function

5. Getter, Setter, WillSet, DidSet

These are used for computed variables

6. Enumerations

Enum is a kind of a ‘label’ or ‘Category’ of a collection of variables. Since those variables belong to a special ‘label’, they share special ‘functions’ and ‘init’ for themselves