• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] JASS private and local variables

Status
Not open for further replies.
Level 9
Joined
Nov 4, 2007
Messages
933
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