Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or enter a complete API identifier.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v0.89.0
Menu

Guards

Require a method value and preview the early return that protects later work.

A missing HUD should stop a refresh before the method reaches it. A guard makes that prerequisite visible at the top of the method.

PlayerController.CollectCoin cannot update score safely unless _scoreCounter and _hud are assigned. Continuing after either value is null would move the failure farther from its cause.

Use Guards when a parameter, field, property, or local must be ready before the rest of a method runs. The picker uses real parsed values, so names are selected, never retyped. It also lists fields you added from the rail that are not compiled yet.

A bool field or property is guarded as a flag. if (!_isConfigured) return; at the top of a method is read as a guard on _isConfigured, the heading over its failure choices reads “If _isConfigured is false…”, and a bool you add from the Guards card gets that guard. A flag is checked on its own; it cannot join a combined check with values tested for null.

The plain failure choices include Stop with an error, Warn and skip the rest of this method, and Warn but carry on. For the early-return shape, choose the option that skips the method when the value is absent.

The Door.Enter graph with early returns
Figure 1. The early-return guards in Door.Enter.

The Guards card begins with No required values yet and Add a check. Its picker title is require a value. Values are grouped as parameters, fields, properties, and locals.

  1. Open a method and find the Guards card in the right rail.
  2. Choose Add a check. The require a value picker opens.
  3. Tick _hud, or another value that must exist before the method continues. Already-required rows say already required and cannot be picked again.
  4. Tick several values when they should be checked together. The confirm action reads Combine N values into one check.
  5. Choose Warn and skip the rest of this method for a non-throwing early return. A non-void method also asks What this method returns when it skips.
  6. Review the draft and its source-shaped preview. Use Add another value to this check to extend a combined guard. While the draft is pending, the card shows Previewing your changes with one action, Discard, which drops the draft.
  7. Press Compile in the toolbar. The guard is written before the protected work, together with any other pending change, and the source is parsed again.
  8. If a value is renamed or removed outside the editor, use Replace value or remove the check before compiling another change.

When it goes wrong

SymptomCheckFix
The picker says Every value is already requiredCompare the existing guard rows.Edit or combine an existing check instead of adding a duplicate.
A guard says Needs a returnConfirm the method returns a value.Choose the value the method returns when it skips.
A row says Value renamed or removedFind the source value that replaced it.Use Replace value, or remove the stale check.
The toolbar Compile is off and says Fix the pending change that needs attention before compilingLook for a guard row with a warning word, such as Needs a return.Apply the row fix, or remove the check, then Compile.
Full-size image