Control flow
Control flow decides which code runs, when it runs, and how often it runs.
Acton does not have a Rust-style match expression. Use
if/elif/else for branching, and combine that with optionals or
exceptions when the question is about absence or failure.
Start with these three everyday tools:
if/elif/elsefor branchingforfor iterating over itemswhilefor repeating while a condition stays true
Loops also support a few extra tools:
breakto stop the loop earlycontinueto skip to the next iterationelseto run code after a loop finishes normally, without abreak
If you are new to programming, start with if,
for, and while and treat loop
else as optional. Most code uses the first three tools far
more often.
for n in range(5):
if n == 2:
continue
if n == 4:
break
print(n)
else:
print("finished without break")
Loop else is tied to break, not to "zero
iterations". It runs whenever the loop finishes normally, which makes it
useful for search-style logic but easy to misread if used casually.
Acton also has actor-specific control patterns such as
after. Those matter once you start
thinking about actors, timers, and concurrency.