Taking Control of Swift Structure

Swift is crammed with power features. These features mean Swift code faces wrapping challenges you don’t encounter in many languages, especially C-like ones. Its complex language elements create an unusually dense declaration style.

Good code layout takes idiomatic language features into account to enhance line-by-line readability. Well-considered choices enable you to focus on code meaning and design intent rather than drawing attention to the minutia of wrapping and bracing. There’s an art to hiding structure and emphasizing intent.

This section explores the basics of spacing and bracing and how you make good choices for both.

Exploring Spacing Concerns

I generally avoid the spacing vs. tabs debate. It doesn’t ...

Get Swift Style now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.