Swift Language
ASecurityUse an enum with associated values when each case carries different typed data: ```swift enum LoadState { case idle case loading case success(User) case failure(Error) } func render(_ state: LoadState) { switch state { case .idle: show("Idle") case .loading: show("Loading") case .success(let user): show(user.name) case .failure(let error): show(error.localizedDescription) } } ``` This is safer than representing mutually exclusive states with several optionals. Use an exhaustive `switch` and e...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
Security analysis
100/100Pro scans all 16 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill swift-language --agent claude-codeAre you the author of Swift Language?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-swift-language-31e26015)Use an enum with associated values when each case carries different typed data:
```swift
enum LoadState {
case idle
case loading
case success(User)
case failure(Error)
}
func render(_ state: LoadState) {
switch state {
case .idle: show("Idle")
case .loading: show("Loading")
case .success(let user): show(user.name)
case .failure(let error): show(error.localizedDescription)
}
}
```
This is safer than representing mutually exclusive states with several optionals. Use an exhaustive `switch` and extract associated values in each matching case.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- eval-4.baseline.md
- eval-4.with-skill.md
- eval-5.baseline.md
- eval-5.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.