Enum/NormalVar
#1

What's better to use enums or just global variables? What take less memory, or the taken memory is the same in both cases?
Example:
pawn Код:
enum My_Enum
{
     var1,
     var2,
     var3,
}new Info[My_Enum];
or
pawn Код:
new
       var1,
       var2,
       var3;
Reply
#2

I don't know what takes less/more memory, but in my opinion, enum is much more easier to work with because all of you variables in one variable which enum controls it. That's what I think, at least.
Reply
#3

Okay, I used to use normal variables and I am fine with them, but I think I have somewhere read that enums take less memory, what isn't logical unless it is a pointer. So I am asking is it worth to learn about enums since I am satisfied with normal Vars
Reply
#4

Enums are often better to use (than an array) because you can have different types like float or arrays. (yes i know PAWN is typless but you know what i mean). If your data is all one type use arrays/vars, if not use arrays of enums.
Reply
#5

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
Okay, I used to use normal variables and I am fine with them, but I think I have somewhere read that enums take less memory, what isn't logical unless it is a pointer. So I am asking is it worth to learn about enums since I am satisfied with normal Vars
I'm not saying it's hard to work with variables, I meant, it's too much variables and dumb to do when you can easily store them into an enum which works with one varaiable or however it works, leave the memroy and enum isn't that hard to learn, here are tutorials.

https://sampwiki.blast.hk/wiki/Keywords:Initialisers#enum
Reply
#6

personaly what i recomend is which you prefer i use normal variables
Reply
#7

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Enums are often better to use because you can have different types like float or arrays. (yes i know PAWN is typless but you know what i mean). If your data is all one type use arrays/vars, if not use arrays of enums.
You can have different types like float or arrays without enums aswell.
pawn Код:
new Float:Var1, Var2[10], Var3;
You can use both, but is it true that enums take less memory?
Reply
#8

PAWN uses cells only, so the size will be the same as its counterpart. Arrays of enums (IMO) are a lot easier to work with than several different variables. Like someone said before use what you prefer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)