Browse Questions
  • An Optional is a type that can hold either a value or nil.
  • Yes — passing an observed property as inout always calls both willSet and didSet, even if the function never modifies the value.
  • The core difference is value type vs reference type.
  • async let starts a child task immediately and lets you await its result later.

Answer: The core difference is value type vs reference type.

structclass
TypeValue typeReference type
MemoryStack (usually)Heap
InheritanceNoYes
MutabilityExplicit (mutating)Implicit
ARCNoYes
deinitNoYes

Rule of thumb:

  • Use struct by default — safer, faster, no retain cycles
  • Use class when you need identity, inheritance, or Objective-C interop