Reserved Words In Swift and How to Escape Them

Become a Subscriber

Swift reserves keywords that can’t be used in as identifiers without being escaped. Examples of identifiers include declarations, statements, expressions, and types. In order to escape a reserved word, put a backtick (`) before and after the word.

Example:

var class: String = "AP History"
// error: expected identifier in class declaration class = "AP History"

var `class`:String = "AP History"
//correctly escaped reserved word 
Declarations

Statements Expressions & Types In Special Contexts
class break as associativity
deinit case dynamicType convenience
enum continue false dynamic
extension default is didSet
func
do nil final
import else self get
init fallthrough Self infix
internal for super inout
let if true lazy
operator in __COLUMN__ left
private return __FILE__ mutating
protocol switch __FUNCTION__ none
public where __LINE__ nonmutating
static while optional
struct override
subscript postfix
typealias precedence
var prefix
Protocol
required
right
set
Type
unowned
weak