Javatpoint Logo
Javatpoint Logo

Swift if-else-if Statement

The if-else-if statement is used when you want to execute one block of code among many.


As long as the test expressions are true, the if statements are executed from top to bottom and then the control of program jumps outside if-else-if ladder.

If the test expression is false, code inside the else is executed.



This number is 0.

You can see that the constant number is initialized with value 0. Since if statements are executed from top to bottom, it checks the expression number > 0 which evaluates to false. It then checks the next expression number < 0 which also evaluates to false.

Hence, the statement print("This number is 0.") inside the else statement.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA