Glossary
info
Tip: CTRL/⌘ + F and type in the symbol or operator you want to look up.
&
(ampersand)
The &
(ampersand) symbol has several uses.
Reference
If an expression starts with the &
(ampersand) symbol, it creates a reference.
_10let a: String = "hello"_10let refOfA: &String = &a as &String
References may also be authorized if the &
symbol is preceded by auth
(otherwise the reference is unauthorized).
Authorized references have the auth
modifier, i.e. the full syntax is auth &T
,
whereas unauthorized references do not have a modifier.
_10let a: String = "hello"_10let refOfA: &String = &a as auth &String
Logical Operator
It can be also used as a logical operator (AND),
by appearing twice in succession (i.e. &&
):
_10let a = true_10let b = false_10_10let c = a && b // false