Swift If-Else Statements & Control Flow Explained | Swift Basics Part 3 (Hindi)

In Part 3 of our Swift Basics series, we explain Control Flow, focusing on If-Else statements, comparison operators, and logical operators in Apple's iOS development ecosystem. ⏱️ Video Chapters (Jump to your answer): 00:00 - What is Control Flow? (Quick Answer) 01:09 - Writing your first 'If' Statement 04:06 - Comparison Operators (==, !=, greater than, less than) 09:00 - Using 'Else' and 'Else If' 13:33 - Logical Operators (AND &&, OR ||) 15:58 - Task: Even and odd program using Swift 👇 CODE SNIPPETS & SUMMARY NOTES BELOW 👇 🚀 Swift Code Cheat Sheet Swift import Foundation // Writing your first 'If' Statement var userAge = 27 if userAge [greater than or equal to] 18 { // code print("Welcome to iOs monk") } // Comparison Operators (==, !=, [greater than], [less than]) // var a = 15, b = 15 // // // Using 'Else' and 'Else If' // if a == b { // print("a is equal to b") // } else if a [greater than] b { // print("a is grater than b") // } else if a [less than] b { // print("a is less than b") // } else { // print("input is invalid") // } // Logical Operators (AND &&, OR ||) var hasAccount = true var hasActiveSubscription = true // AND Operator (&&) if hasAccount && hasActiveSubscription { print("Play Movie") } // OR Operator (||) var isVIP = false var hasPass = true if isVIP || hasPass { print("Enter the Event") } ================ 🧠 Summary Notes What are If-Else Statements in Swift? If-Else statements are fundamental control flow tools in Swift. They allow your application to make decisions by executing specific blocks of code only if a given condition evaluates to true. If the condition is false, the application can either do nothing, check another condition (else if), or execute a default block of code (else). What is the difference between = and == in Swift? A single equal sign (=) is the assignment operator; it assigns a value to a variable or constant. A double equal sign (==) is the equality comparison operator; it checks if two values are exactly identical and returns a Boolean (true or false). What do && and || mean in Swift? AND (&&): Requires both conditions on the left and right to be true for the entire statement to be true. OR (||): Requires only one of the conditions (left or right) to be true for the entire statement to be true. 📑 Frequently Asked Questions (FAQ) Q: Can I use multiple 'else if' statements? A: Yes. You can chain as many 'else if' statements together as your logic requires before ending with a final 'else' block. Q: Do I always need an 'else' block? A: No. An 'if' statement can function perfectly on its own if you only want an action to occur when a condition is true, and nothing to happen if it is false. =============== social handles Instagram:   / weareiosmonk   #iOSMonk #SwiftUI #SwiftBasics #ControlFlow #LearnSwift #CodingInHindi