Press escape to exit fullscreen

{{sketch.instructions}}

CC {{sketch.licenseObject.short}}

Archived Sketch

This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.

View Source Code

Capture Screenshot

Break From Nested Statements Using Labels

{{$t('general.by')}}
If we have nested iterating statements, like the for loop within a while loop below, a single 'break' cannot get us out of the outer loop. Since the while loop here will always evaluate true, we would be stuck infinitely running it. Instead, add a label before the outer loop in the following format: <labelName>: This is then called inside the nested loop with the standard 'break' followed by the label: break <label>; Below we have a while loop that iterates continuously; inside it a for loop adds 1 to a value n, 10 at a time. When it reaches the target value of 100, it breaks both loops a
We recovered an unsaved version of this sketch. Please review your changes below.

As a Plus+ Member feature, this source code is hidden by the owner.

  • {{co.title}}
    {{$t('sketch.mode-pjs')}} {{$t('general.learnMore')}}
    Select mode or a template
    {{liveCodeLink}}
    • {{l.url.substr(l.url.lastIndexOf('/') + 1)}}
    {{$t('sketch.layoutDescription')}}

    {{k.category}}
    {{k.label}}
    {{k.description}}

    {{$t('sketch.seeMoreShortcuts')}}

    Versions are only kept for 7 days.
    Join Plus+ to keep versions indefinitely!

    {{$t('general.joinPlus')}}


    {{$t('sketch.versionsSummarized')}}