Keywords
The following list contains keywords that are reserved for current or future use by the Sway language. As such, they cannot be used as identifiers. Identifiers are names of functions, variables, parameters, modules, constants, attributes, types or traits, etc.
Keywords Currently in Use
The following is an alphabetically sorted list of keywords currently in use, with their functionality shortly described.
as
- rename items inuse
statements, e.g.,use type::type_name as alias_name;
abi
- define a smart contract ABI in a syntactically similar way to traitsasm
- define an assembly blockbreak
- exit a loop immediatelyconfigurable
- define configurable constantsconst
- define constantcontinue
- continue to the next loop iterationcontract
- define contract program typeelse
- used in conjunction withif
conditions for control flow constructsenum
- define an enumfalse
- Boolean false literalfor
- loop based on iteratorsfn
- define a functionif
- branch based on the result of a conditional expressionimpl
- implement inherent or trait functionalitylet
- bind a variablelibrary
- define library program typematch
- exhaustively match a value to patternsmod
- define a modulemut
- denote mutabilitypub
- denote public visibilitypredicate
- define predicate program typeref
- bind by referencereturn
- return early from a functionscript
- define script program typeSelf
- a type alias for the type we are defining or implementingself
- method call targetstorage
- define a storage declarationstr
- string slicestruct
- define a structuretrait
- define a traittrue
- Boolean true literaltype
- define a type alias or associated typeuse
- bring symbols into scopewhere
- specifies trait constraints for generic type argumentswhile
- loop conditionally based on the result of an expression
Keywords Reserved for Possible Future Use
abstract
async
await
become
box
do
dyn
extern
for
in
loop
macro
move
override
priv
static
super
try
typeof
unsafe
unsized
virtual
yield