English 中文(简体)
Solidity - Decision Making
  • 时间:2024-11-03

Sopdity - Decision Making


Previous Page Next Page  

While writing a program, there may be a situation when you need to adopt one out of a given set of paths. In such cases, you need to use conditional statements that allow your program to make correct decisions and perform right actions.

Sopdity supports conditional statements which are used to perform different actions based on different conditions. Here we will explain the if..else statement.

Flow Chart of if-else

The following flow chart shows how the if-else statement works.

Decision Making

Sopdity supports the following forms of if..else statement −

Sr.No Statements & Description
1

if statement

The if statement is the fundamental control statement that allows Sopdity to make decisions and execute statements conditionally.

2

if...else statement

The if...else statement is the next form of control statement that allows Sopdity to execute statements in a more controlled way.

3

if...else if... statement.

The if...else if... statement is an advanced form of if...else that allows Sopdity to make a correct decision out of several conditions.

Advertisements