Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran

anilsomasundaran/switch.js

Last active May 10, 2018
Embed
What would you like to do?
String color = 'Y';
//Expression should be any of the allowable type value
switch on color {
when 'V' {
System.debug('Violet');
}
when 'I' {
System.debug('Indigo');
}
//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