Skip to content

Instantly share code, notes, and snippets.



Last active May 10, 2018
What would you like to do?
String color = 'Y';
//Expression should be any of the allowable type value
switch on color {
when 'V' {
when 'I' {
//Multiple values given as comma seperated
when 'B','G' {
System.debug('Blue or Green');
when 'Y','O','R' {
System.debug('Yellow or Orange or Red');
when null {
System.debug('Bad Value');
when else {
System.debug('Not in spectrum');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment