In nearly every programming language, there is the option to use statements such as if
and else
. Often, we need to use loops such as the for
loop. Statements and loops make a programmer's life much easier when it comes to keeping code readable and organized, so let's take a look at how these look in GML.
Loops allow developers to greatly reduce the amount of code needed to execute a repetitive task. Instead of using multiple if
statements, the programmer can summarize it all into a single loop, keeping the code short and concise.
First, we will look at the simpler of the two statements. We will begin with the most commonly used statement, the if
statement.