Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran
Last active May 10, 2018 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsomasundaran/d2448276cdc9e517375a7dffd74092da to your computer and use it in GitHub Desktop.
Save anilsomasundaran/d2448276cdc9e517375a7dffd74092da to your computer and use it in GitHub Desktop.
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