Last active
May 10, 2018 18:01
-
-
Save anilsomasundaran/a3e9041a3f56212693d017268c3f84f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sobject obj = null; | |
switch on obj { | |
//checks whether the obj is an instance of Account. | |
//if yes, obj is casted to acc with relevant values | |
when Account acc { | |
System.debug('account ' + acc); | |
} | |
//checks whether the obj is an instance of Contact. | |
//if yes, obj is casted to con with relevant values | |
when Contact con { | |
System.debug('contact ' + con); | |
} | |
//checks obj == null | |
when null { | |
System.debug('null'); | |
} | |
// default block | |
when else { | |
System.debug('default'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment