Swift Print Variables

🖨️ Swift Print Variables
Swift provides a simple, safe, and powerful way to do this using print().
1. Printing a Single Variable
Output
2. Printing Variable with Text (Best Method ✅)
Use string interpolation \( ).
Output
✔ Safe
✔ Clean
✔ Recommended
3. Printing Multiple Variables Together
Output
4. Printing Different Data Types
5. Printing Multiple Variables in One Sentence
Output
6. Custom Separator
Output
7. Custom Terminator (No New Line)
Output
8. Printing Optional Variables
9. Using debugPrint() for Variables
Used mainly for debugging, shows more detail for complex data.
❌ Common Mistake (Very Important)
Wrong ❌
Correct ✅
🧠 Summary Table
| Task | Correct Way |
|---|---|
| Print variable | print(varName) |
| Text + variable | "Text \(var)" |
| Multiple vars | print(a, b) |
| Optional var | var ?? default |
| Debug output | debugPrint() |
