Swift updates
Learn about important changes to Swift.
Adopting strict concurrency in Swift 6 apps
Enable strict concurrency checking to find data races at compile time.
Swift includes modern features like type inference, optionals, and closures, which make the syntax concise yet expressive. Swift ensures your code is fast and efficient, while its memory safety and native error handling make the language safe by design. Writing Swift code is interactive and fun in Swift Playgrounds, playgrounds in Xcode, and REPL.
var interestingNumbers = [
"primes": [2, 3, 5, 7, 11, 13, 17],
"triangular": [1, 3, 6, 10, 15, 21, 28],
"hexagonal": [1, 6, 15, 28, 45, 66, 91]
]
for key in interestingNumbers.keys {
interestingNumbers[key]?.sort(by: >)
}
print(interestingNumbers["primes"]!)
// Prints "[17, 13, 11, 7, 5, 3, 2]"
If you’re new to Swift, read The Swift Programming Language for a quick tour, a comprehensive language guide, and a full reference manual. If you’re new to programming, check out Swift Playgrounds on iPad.
Swift is developed in the open. To learn more about the open source Swift project and community, visit Swift.org.
struct Int
struct Double
struct String
struct Array
struct Dictionary
id
type to a specific Swift type.func withTaskCancellationHandler <T>(operation: () async throws -> T, onCancel : () -> Void, isolation: isolated (any Actor)?) async rethrows -> T