March 2017
Intermediate to advanced
226 pages
5h 13m
English
When arriving in Swift from a semicolon-delimited language, you need to adjust your thinking. Rather than terminating statements, approach semicolons as “statement glue.” In Swift, semicolons enable you to join related components onto a single line, blending two thoughts into a single group:
| | defer { x = x + 1 }; return x // duplicates x++ |
This is not a widely adopted style—Swift purists prefer to omit semicolons entirely—but it is a useful one. For example, I often use a PushDraw function to temporarily change the characteristics of an active drawing context. Because the scope of each request is so short, I often present them as a single line. Semicolons enable me to treat a two-stage request as a single ...
Read now
Unlock full access