Reference types vs Value types

  • Classes are Reference types
  • Enum and Struct are Value types

Reference types: assignment means pointing to same address location

Value types: assignment means copy to the new thing.


  • even if be declared by let keyword (means be constant), classes can be modified
  • for struct, if it's be declared as constant with let keyword, it cannot be modified. It's still true if it's be declared as variable with var keyword. But in this case, you can modified it with mutating keyword in function declaration
  • enum doesn't have stored property, so it doesn't relate here.


deinit is only available for classes. Because classes are reference types, so they are concerned by Reference counting process.

Generated init

only with struct, swift generates init methods base on properties.


only class supports inheritance.

Stored property

only enum cannot contain a Stored Property. Stored Property là một property của class hoặc struct, có thể được gán giá trị (để phân biệt với computed property)

Properties - The Swift Programming Language (Swift 5.2)