Statements Group expressions and control the flow of execution. In Swift, there are three kinds of statements: simple statements, compiler control statements, and control flow statements. Simple statements are the most common and consist of either an expression or a declaration. Compiler control statements allow the program to change aspects of the compiler’s behavior and include a conditional compilation block and a line control statement. Control flow statements are used to control the flow of execution in a program....

Summary of the Grammar Read the whole formal grammar. Lexical Structure Grammar of whitespace: whitespace → whitespace-item whitespace? whitespace-item → line-break whitespace-item → inline-space whitespace-item → comment whitespace-item → multiline-comment whitespace-item → U+0000, U+000B, or U+000C line-break → U+000A line-break → U+000D line-break → U+000D followed by U+000A inline-spaces → inline-space inline-spaces? inline-space → U+0009 or U+0020 comment → // comment-text line-break multiline-comment → /* multiline-comment-text */ comment-text → comment-text-item comment-text?...

Types Use built-in named and compound types. In Swift, there are two kinds of types: named types and compound types. A named type is a type that can be given a particular name when it’s defined. Named types include classes, structures, enumerations, and protocols. For example, instances of a user-defined class named MyClass have the type MyClass. In addition to user-defined named types, the Swift standard library defines many commonly used named types, including those that represent arrays, dictionaries, and optional values....