You need to sign in to do that
Don't have an account?
jgrenfell
Unable to do Switch (case) statement
I'm trying to do a switch statement in Apex, I'm assuming the syntax will be like java, but I can't seem to get it to compile; I get an "unexpected token: {" error message. Am I missing something obvious? I have many more cases to add and I'm hoping I don't have to do if statements for each one.
Code:
Code:
switch (ce_days) { case 180: milestone = 180; }//end switch
You could try an if...else if statement instead.
if (place = 1) {
medal_color = 'gold';
} else if (place = 2) {
medal_color = 'silver';
} else if (place = 3) {
medal_color = 'bronze';
} else {
medal_color = null;
}
Refer this ideahttps://success.salesforce.com/ideaview?id=08730000000BrSIAA0