Swift if, if...else Statement

Article by: Manish Methani

Last Updated: October 13, 2021 at 8:04am IST
2 mins 51 sec read

Sometimes in a program we need to test a condition. If that condition is true we perform first action and if the condition is false we perform second action.

Now what does that mean?

1) Simple if Statement

if statement is used to test a given condition. If given condition is satisfied then only block inside if statement will gets executed.

Example :-

import UIKit
var a:Int = 10

if(a == 10)
{
 print("a = (a)")
}

Output :-

a = 10

In this swift program we first initialised a variable "a" with value "10" . Then if condition checks wether 'a == 10' or not . Since value matches block inside if is executed. That's why output 'a = 10' .

Discover My FlutterFlow Courses and Template Apps

FlutterFlow Course: Dating App from Scratch
Learn to Create the Dating App with Admin Dashboard using No-Code Tool FlutterFlow in this comprehensive course with Clone App Access.
FlutterFlow Course: Grocery Delivery App with Admin Dashboard
Learn to Create Grocery Delivery App with Admin Dashboard using No-Code Tool FlutterFlow in this comprehensive course with Clone App Access.
FlutterFlow Course: Online Courses App from Scratch
Learn to Create an Online Courses App with Course Tracking using No-Code Tool FlutterFlow in this comprehensive course with Clone App Access.
Codzify Logo

Terms and Conditions    Cookie Policy   Refund Policy   Adsense Disclaimer

Contact: [email protected]