HomeSearch

Swift Keywords

Review keywords in the Swift language. These keywords are used throughout Swift programs.
Keywords. Like other languages Swift is made up of keywords. We find many well-known keywords like for and if. But others, like guard, are also found.
In Swift 3, many different reserved keywords are used. We cannot name a variable with those names. This makes programs easier to understand.associativitybreakcasecatchclasscontinueconveniencedefaultdeinitdidSetdoelseenumextensionfallthroughfalsefinalforfuncgetguardifininfixinitinoutinternallazyletmutatingniloperatoroverridepostfixprecedenceprefixprivatepublicrepeatrequiredreturnselfsetstaticstructsubscriptsuperswitchthrowstruetryvarweakwherewhilewillSet
Functions. Some common things in Swift are not keywords. Functions like print() are built into the language. We can call them directly in a Swift program.absmaxminprint
Important types. This language has built-in types like array, dictionary and set. These types can be accessed directly—they are used throughout programs.ArrayBoolDictionaryErrorIntSetStringTupleUnicodeScalar
Syntax. In Swift, syntax is close to many other languages. We find few vertical bars and confusing symbolic chains. But some operators may be unexpected.x: (Argument name x)[T] (Array of T elements)<T> (Generic type)?-- (Optional decrement)?++ (Optional increment)x? (Optional type)x! (Optional value access)&+ (Overflow add)&* (Overflow multiply)&- (Overflow subtract)0...2 (Range)0..<2 (Range, half-open)T... (Repeated argument)-> (Return type)"\(x)" (String interpolation)x ? 0 : 1 (Ternary).0 (Tuple item 0)
Foundation types. Swift programs use many Foundation library features. For example, they use NSString directly. This provides many additional features not exclusive to Swift.CharacterSetNSStringNSString.CompareOptionsString.Encoding.ascii
UIKit. Usually we do not learn Swift as a mind exercise. Instead we want to develop iOS applications—iPhone programs. We need UIKit for this.UIKit
Apple documentation. The keywords in Swift are described in the Apple documentation. The documentation begins with the var and let keywords.Swift, The Basics: apple.com
Features. Swift supports many styles of programming. An iPhone does not operate on magic. As a Swift developer, you can tap into its powerful frameworks and create beautiful things.
© 2007-2019 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
Home
Dot Net Perls