Skip to content

Instantly share code, notes, and snippets.

@AppleCEO
Created August 20, 2025 06:35
Show Gist options
  • Save AppleCEO/82f7d3e3e20b66d2421f6eec69d1857b to your computer and use it in GitHub Desktop.
Save AppleCEO/82f7d3e3e20b66d2421f6eec69d1857b to your computer and use it in GitHub Desktop.
let data: [Any] = [Date(), "string", 123]
for elem: Any in data {
switch elem {
case let stringVal as String: // handle string
case let intVal as Int: // handle integer
case let dateVal as Date: // handle date
default: // handle others
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment