Hello, so for my project i'm using a switch statement to return int values. So like so...
How me code works is it sets a value for x to either 1 or 2, choosing the correct case and returning the correct value, however, if a certain condition is met, I want it to return the default value, so lets say the condition is as follows...
So because y is 2. x should be returned as 9. Any help is greatly appreciated, thanks!
switch(x) {
case 1:
return 1;
case 2:
return 3;
default:
return 9;
}
How me code works is it sets a value for x to either 1 or 2, choosing the correct case and returning the correct value, however, if a certain condition is met, I want it to return the default value, so lets say the condition is as follows...
x = 1;
y = 2;
if(y == 2) {
//set value to default
}
So because y is 2. x should be returned as 9. Any help is greatly appreciated, thanks!