Swift BasicsLesson 15Free preview
Swift If...Else
This lesson is part of Swift · All levels
Summary
This lesson discusses conditional branching using 'if', 'else if', and 'else' in Swift. In Swift, the condition does not require regular parentheses around it, but the curly braces of the opening and closing instruction block are always required to be written. The condition must be a pure boolean expression without implicit conversion of an integer.
Key points
- Conditional statements using the keywords 'if' and 'else'
- Common parentheses around the condition are optional and commonly eliminated
- Curly braces '{' and '}' for body code are always mandatory to write
- Bool type compulsory condition (number 1 is not considered implied)
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.