Akolyt0r
New Member
- Reaction score
- 33
Hi, i am a bit unsure when i need to nullify local vars, and/or when i should use them
3 possibilites:
i know for some types i have defintly choose option 2...(e.g: Locations or Groups), but what about the others ...?
and i know i always should use locals when i use some stuff (e.g. GetTriggerUnit() )quite often ...but what when i use it only one time, should i still use locals, because they leak (do they ?!) ??
3 possibilites:
JASS:
local integer i=0
local player p
//1: locals, nullify only at the end
loop
exitwhen i>11
set p=Player(i)
call DisplayTextToPlayer(p,0,0,"Some Text")
set i=i+1
endloop
set p=null
JASS:
//2: locals, nullify everytime i assigned a different value
local integer i=0
local player p
loop
exitwhen i>11
set p=Player(i)
call DisplayTextToPlayer(p,0,0,"Some Text")
set p=null
set i=i+1
endloop
JASS:
//3: no locals
local integer i=0
loop
exitwhen i>11
call DisplayTextToPlayer(Player(i),0,0,"Some Text")
set i=i+1
endloop
i know for some types i have defintly choose option 2...(e.g: Locations or Groups), but what about the others ...?
and i know i always should use locals when i use some stuff (e.g. GetTriggerUnit() )quite often ...but what when i use it only one time, should i still use locals, because they leak (do they ?!) ??