Where should I declare variable with good performance
#3

1. The first solution is called local variable, Which means it can only be accessed within the function it is declared into only and then it is removed from memory.
The second solution is called global variable, Which as the name suggests it can be accessed anywhere inside your script and it always has a place allocated in memory.

When to use? It depends on your use case, For example a variable that keeps track of player kills then that must be global because we want to access it anywhere and it needs to keep counting the kills,.

But there is cases where you can use both without a problem, Then local variables is more optimized because it is removed after you finish using it so it frees space in the memory.
---------
2. Sure why not.
Reply


Messages In This Thread
Where should I declare variable with good performance - by SamBum - 09.10.2018, 03:51
Re: Where should I declare variable with good performance - by NaS - 09.10.2018, 04:26
Re: Where should I declare variable with good performance - by FailerZ - 09.10.2018, 04:28
Re: Where should I declare variable with good performance - by SamBum - 09.10.2018, 04:42
Re: Where should I declare variable with good performance - by TheToretto - 09.10.2018, 11:40
Re: Where should I declare variable with good performance - by SamBum - 11.10.2018, 07:54

Forum Jump:


Users browsing this thread: 1 Guest(s)