Features
- Inferred Types, to make code cleaner and less prone to mistakes.
- Modules eliminate headers and provide namespaces.
- Memory is managed automatically.
- Don’t even need to type semi-colons.
- Code written at global scope is used as the entry point for the program, so you don’t need a main() function.
- Named parameters brought forward from Objective-C are expressed in a clean syntax that makes APIs in Swift easy to read and maintain.
- Closures unified with function pointers
- Tuples and multiple return values
- Generics
- Fast and concise iteration over a range or collection
- Structs that support methods, extensions, and protocols
- Functional programming patterns, e.g., map and filter
- Powerful error handling built-in
- Advanced control flow with do, guard, defer, and repeat keywords
- Swift has an innovative feature known as optionals