Skip to main content
Discovery icon for Minecraft Computer Mods Discord server

Minecraft Computer Mods

2,040 Online
7,347 Members
# computercraft3 people

replacing break statements

A discussion on how to implement program logic without using `break` statements, suggesting alternative loop structures or condition flags.

  • Using `repeat until` loops or upvalues for `while` loop conditions can help manage loop flow without `break` statements.
  • A common strategy is to use an `else` branch for the remainder of the code after a conditional exit point.
  • One method to replace a `break` is to introduce a boolean flag that is set to `true` when the `break` condition is met, and then include this flag in the `while` loop's header condition.
Summarized from recent messages, might be inaccurate

More conversations

Talk, Play, &
Hang Out

Find your space to hang out, discuss the latest updates with the party chat, and see who's down to join your next match.
Get App