- What is the difference between
varandlet?
letis a constant variable and thus can be assigned once only -- its value is immutable.varis a variable that can be assigned multiple times -- its value is therefore mutable.
- What is an Optional? What happens when using the
if letsyntax?
- An Optional is a wrapper around an object instance that returns
nilwhen said instance doesn't have a valid value. - Using
if letallows you to test an Optional instance againstniland change control flow depending on the result. The process of assigning an Optional to a variable inside a conditional statement is called 'Optional Binding'.