Question about 'static'
#1

I only recently learned that they "static" variables don't loose their value between calls.


And i instantly thought: gates! They're just perfect for them! Becaus I hate having global variables for them...

But someone should have thought of that....

Getting to the question part,
are there downsides to them? Are they somehow worse than global ones? Should I or should I not use them?


ANY feedback will be appreciated
Reply
#2

I'm my opinion I wouldn't use them, they are a hastle. -- But it's what you want to.
Reply
#3

Quote:
Originally Posted by Parker_Daley
Посмотреть сообщение
I'm my opinion I wouldn't use them, they are a hastle. -- But it's what you want to.
That's the thing, i want a reason, why wouldn't you use them?
Reply
#4

I just think they are a inconvenience.
Reply
#5

bump
Reply
#6

Static variables are global variables that you can use only in specific block.
If you want to make a global variable that exists only between { and } use static.
If you want to use the variable outside use normal global.
I would use static for gates. Why? When I use static, outside the block I can declare another variable with same name without getting warnings.
Reply
#7

static variables are almost the same thing was local variables, the unique difference is that the variable is not deleted after executing the function, so, you can use the content of the variable when you run that function again. [talking about the static local]


@Edit -> https://sampwiki.blast.hk/wiki/Scripting...s#static_local
Reply
#8

Also global static exists only for single file, and won't be visible in other files namespace
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)