🍃 Swift Conditional Statements
Use conditions to run different code based on different values or circumstances. Swift supports if
, else if
, else
, and switch
statements.
📝 Example: if
/ else
Output will appear here...
📖 Condition Syntax Notes
- Conditions are written inside parentheses
()
.
- Code blocks are enclosed in curly braces
{ }
.
- Use
else if
for multiple branches.
- Use
switch
for checking multiple exact values.
💡 Tip: Swift switch cases must be exhaustive — cover every possible case or add a default
.