Verse Library verse

01 Fragment

Demonstrates how to declare public and private functions to control cross-script access and encapsulation.

verse-library/specifiers/01-fragment.verse

# This is our Light Controller script.

# We define a function called TurnOn.
# The word 'public' is the specifier.
# It means ANY other script can call this.
TurnOn := function() {
    # Here we would tell the Neon Sign to glow.
    # For this tutorial, we just print a message.
    Print("The neon sign is now ON!")
}

# We also define a private function.
# It has no 'public' label.
# Only THIS script can use it.
HideLights := function() {
    Print("The lights are hidden.")
}

Comments

    Sign in to vote, comment, or suggest an edit. Sign in