• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] JASS private and local variables

Status
Not open for further replies.
Level 9
Joined
Nov 4, 2007
Messages
931
I'm tryin to learn to do more advanced triggers, and I feel like I may eventually need to learn how to use different kinds of variables, so what I'd like to know is what is a private variable and how is it different than local and global ones? Thanks in advance for responding.
 
Level 11
Joined
Feb 22, 2006
Messages
752
If you're talking about vJASS, private variables have to do with encapsulation. Private variables (and functions and structs) can only be accessed inside the scope in which they are declared. So if you do:

JASS:
scope A
globals
    private integer i
endglobals
endscope

scope B
    function foo takes nothing returns nothing
        set i = 2
    endfunction
endscope

You would get a compile error because function foo in scope B is trying to access a private variable in another scope.


If you have no idea wut vJASS is, then I have no idea what you're talking about cuz plain JASS doesn't have encap.
 
Status
Not open for further replies.
Top