Plurality

Plurality plays an interesting role in Swift naming. Most Swift types should be single—but not option sets. Most Swift instances should be single, but many collection instances work better as plurals. This section overviews how plurality affects naming across a number of Swift elements you encounter when designing your APIs.

Protocols

Protocols, from Hashable to SetAlgebra to Sequence, are universally singular. Avoid plurals like Numbers or Incrementables. A protocol describes a single semantic quality. Using plural words incorrectly describes the items that conform to the protocol instead of describing the semantics that conformance guarantees.

Enumerations

An enumeration reads as a singular thing: PaperSize, HTTPResponse, DayOfTheWeek ...

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.