I'm learning about Pawn language . I'm having trouble with parameters in the enum function
enum E_MY_TAG (<<= 1)
{
E_MY_TAG_NONE,
E_MY_TAG_VAL_1 = 1,
E_MY_TAG_VAL_2,
E_MY_TAG_VAL_3,
E_MY_TAG_VAL_4
}
new
E_MY_TAG:gMyTagVar = E_MY_TAG_VAL_2 | E_MY_TAG_VAL_3;
I learned that the values in the enum will increment by default by +=1
And my lesson says the code :
new E_MY_TAG:gMyTagVar = E_MY_TAG_VAL_2 | E_MY_TAG_VAL_3;
That will create a new variable and assign it the value 6 (4 | 2)
I don't understand it , why the value of E_MY_TAG_VAL_2 is 4 and E_MY_TAG_VAL_3 is 2 and the parameter in the enum function why it is <<=1 , i remember there is no such operator
This enumerator contains bit flag values. First enum value is implicitly initialized with 0, second is explicitly initialized with 1, and the rest are initialized by applying
<<=1(left bit shift operator that is essentially equivalent to multiplying by 2) to the previous value and will be 2, 4, 8.gMyTagVaris composed usingbitwise ORoperator. You may want to get familiar with bitwise operations.