Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "break"

From Quake Wiki

(Created page with "<code>break</code> causes execution to exit a loop.")
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<code>break</code> causes execution to exit a loop.
+
''void'' '''break'''()
 +
 
 +
== Usage ==
 +
Breaks out of a loop similar to the standard <code>break</code> keyword in other programming languages. This is largely deprecated in favor of using <code>break</code> as a keyword in modern QuakeC compilers.
 +
 
 +
== Example ==
 +
for (float i = 0; i < cap; ++i)
 +
{
 +
    PerformFirstTask();
 +
 +
    // If the entity died in the first task, exit the loop early
 +
    if (self.health <= 0)
 +
        break;
 +
 +
    PerformSecondTask();
 +
}
 +
 
 +
[[Category:QuakeC Function]]

Latest revision as of 10:55, 31 July 2023

void break()

Usage[edit]

Breaks out of a loop similar to the standard break keyword in other programming languages. This is largely deprecated in favor of using break as a keyword in modern QuakeC compilers.

Example[edit]

for (float i = 0; i < cap; ++i)
{
    PerformFirstTask();

    // If the entity died in the first task, exit the loop early
    if (self.health <= 0)
        break;

    PerformSecondTask();
}