Swift Keywords

Welcome to Swift Tutorial. In this tutorial, we will learn about the reserved keywords in Swift programming.

Swift keywords are the words reserved for a purpose.

They cannot be used for variable names constants or any other identifiers.

There are four types of keywords in Swift based on the location of their usage in a swift program.

  • Keywords in Declarations
  • Keywords in Statements
  • Keywords in Expressions and Types
  • Keywords in Specific Contexts

Swift Keywords used in Declarations

ClassdeinitEnumextension
FuncimportInitinternal
Letoperatorprivateprotocol
publicstaticstructsubscript
typealiasvar

Swift Keywords used in Statements

breakcasecontinuedefault
doelsefallthroughfor
ifinreturnswitch
wherewhile

Swift Keywords used in Expressions and Types

asdynamicTypefalseis
nilselfSelfsuper
true_COLUMN__FILE__FUNCTION_
_LINE_

Swift Keywords used in Specific Contexts

associativityconveniencedynamicdidSet
finalgetinfixinout
lazyleftmutatingnone
nonmutatingoptionaloverridepostfix
precedenceprefixProtocolrequired
rightsetTypeunowned
weakwillSet

We shall go through all these keywords in this series of Swift Tutorial and explain in detail with examples when necessary.