Conditional blocks
Often, it is a requirement to perform certain routines based on the outcome of an operation. In any programming language, we can achieve this via conditionals such as an if
statement or a match
block. In this section, we will gain an understanding of each of the conditional blocks offered by V in further detail. We will begin our discussion with the if
statement.
The if statement
Conditionals such as if
and if-else
blocks in V allow you to make decisions based on the outcome of the condition being evaluated in the statement. The evaluation might involve the result of logical or relational operators. The if
statement in V allows you to create a special code block that will only be executed upon satisfying the condition mentioned in the if
statement. The following is the syntax for writing an if
block:
if CONDITION { // CONDITION evaluated to true }
The preceding syntax demonstrates how to write an if
statement...