Continue class¶
This page explains the Continue
class.
Before reading on, maybe it is helpful to read the following page (apysc uses the Continue
class for the same reason):
What is the Continue class?¶
The with For
block uses the Continue
class to skip a current loop iteration (in JavaScript). It behaves like the Python built-in continue
keyword.
Basic usage¶
The Continue
class can only be used in the with For
(or other loop class) block, as follows:
import apysc as ap
ap.Stage(
stage_width=250, stage_height=150, background_color="#333", stage_elem_id="stage"
)
sprite: ap.Sprite = ap.Sprite()
arr: ap.Array = ap.Array(range(2))
i: ap.Int
with ap.For(arr) as i:
condition: ap.Boolean = i == 0
with ap.If(condition):
sprite.graphics.begin_fill(color="#0af")
sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
ap.Continue()
sprite.graphics.begin_fill(color="#f0a")
sprite.graphics.draw_rect(x=150, y=50, width=50, height=50)
ap.save_overall_html(dest_dir_path="continue_basic_usage/")
If you use the Continue
class in the out of the with For
block, then an exception is raised:
import apysc as ap
ap.Continue()
Exception: The `Continue` class can be instantiated in the with loop statement, for example, after the `with ap.For(...):` statement.
Continue API¶
Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.
[Interface signature] __init__(self) -> None
[Interface summary]
The loop continue expression class.
[Notes]
This class can be instantiated in the with loop statement, for example, after the with ap.For(...):
statement.
[Examples]
>>> import apysc as ap
>>> arr: ap.Array = ap.Array(range(3))
>>> with ap.For(arr) as i:
... with ap.If(i == 1):
... _ = ap.Continue()
...