language-swift
Installation
SKILL.md
Swift
Optionals
?makes absence explicit in the type —String?vsString.if let/guard letunwrap safely.guardexits scope immediately — prefer it for preconditions.??provides a default fornil. Never force-unwrap (!) in production unless the nil case is a programmer error that should crash loudly.
guard let email = user.email else { return }
let display = nickname ?? username
Value vs reference types
- Default to
struct— value semantics, copy-on-write, no shared-mutation bugs. - Use
classonly when identity matters (reference equality, inheritance), or when Objective-C interop requires it. - Use
actorto encapsulate mutable state that must be safe to access from multiple async tasks.