Swift Introz
Swift Build apps using a powerful open language. Available: iOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+, visionOS 1.0+
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.
Below is a code snippet in Swift.
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 .