First off I want to mention that I have not started any coding yet. I was simply wondering if there is coding syntax that allows you to declare a variable with multiple same type values. For example, a variable named Operation; where Operation can be equal to either 1, 32 or 58 let say. Here is a psudo code example…
int ArrayPlus1 = myArray[0]+1; //could add 1 to an array element.
int ArrayPlus32= myArray[0]+32; //could add 32 to an array element.
int ArrayPlus58= myArray[0]+58; //could add 58 to an array element.
int x;
declare Operation {
ArrayPlus1,
ArrayPlus32,
ArrayPlus58
}
loop {
if(x = Operation) {
//do something here. That means x is either equal to array[0]+1, array[0]+32 or array[0]+58.
} //end if
} //end loop
I understand that I can just use a multiple if statement…“if this or this or this then that”. But I was just wondering if it is possible to code a variable that has multiple values. I have tried using enum and struct without any luck. So I am not sure what to try next. Enum would not allow me to use an array and struct I had to use the syntax Operation.ArrayPlus1 specifiically and not just the Operation variable
Thanks and I hope this is not too confusing. Any comments are super welcome. This is not a priority in any way…just pure curiosity.
Scott