keywords and identifiers
Keywords used in declarations:
class, deinit, enum, extension, func, import, init, inout, internal, let, operator, private, protocol, public, static, struct, subscript, typealias, varKeywords used in statements:
break, case, continue, default, defer, do, else, fallthrough, for, guard, if, in, repeat, return, switch, where, whileKeywords used in expressions and types:
as, catch, dynamicType, false, is, nil, rethrows, super, self, Self, throw, throws, true, try, __COLUMN__, __FILE__, __FUNCTION__, __LINE__Keywords used in patterns:
_Keywords reserved in particular contexts:
associativity, convenience, dynamic, didSet, final, get, infix, indirect, lazy, left, mutating, none, nonmutating, optional, override, postfix, precedence, prefix, Protocol, required, right, set, Type, unowned, weak, willSetOutside the context in which they appear in the grammar, they can be used as identifiers.
The following tokens are reserved as punctuation and can’t be used as custom operators:
(, ), {, }, [, ], ., ,, :, ;, =, @, #, & (as a prefix operator), ->, `, ?, and ! (as a postfix operator)关键字和符号
下面这些被保留的关键字(keywords)不允许用作标识符,除非被反引号转义,具体描述请参考 标识符。
- 用在声明中的关键字:
class、deinit、enum、extension、func、import、init、let、protocol、static、struct、subscript、typealias、var- 用在语句中的关键字:
break、case、continue、default、do、else、fallthrough、if、in、for、return、switch、where、while- 用在表达式和类型中的关键字:
as、dynamicType、is、new、super、self、Self、Type、__COLUMN__、__FILE__、__FUNCTION__、__LINE__- 用在模式中的关键字:
_- 特定上下文中被保留的关键字:
associativity、didSet、get、infix、inout、left、mutating、none、nonmutating、operator、override、postfix、precedence、prefix、right、set、unowned、unowned(safe)、unowned(unsafe)、weak、willSet这些关键字在特定上下文之外可以被用于标识符。
- 以下标记被当作保留符号,不能用于自定义操作符:
( 、 ) 、 { 、 } 、 [ 、 ] 、 . 、 , 、 : 、 ; 、 = 、 @ 、 # 、 &(作为前缀操作符) 、 -> 、`` 、 ? 和 !(作为后缀操作符)`。