Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 672 Bytes

choosing-between-structs-and-classes.md

File metadata and controls

12 lines (7 loc) · 672 Bytes

Choosing Between Structures and Classes

In addition to the Apple guidelines, we generally prefer to use struct for:

But consider using class instead if:

  • You need to manage mutable states. Especially if there are more than a few mutating functions, the struct becomes harder to reason about.
  • You have to set a struct property declaration as var because it has a mutating function. In this case, a constant (let) class property may be easier to reason about.