It is almost 18 months since Salesforce finally introduced one of the most eagerly anticipated features for Apex - switch statement . Does it even make sense to comment it today? I can only guess it was because of general familiarity with the switch statement , good documentation or simply happiness over surprising birth of a son you stopped dreaming about years ago, but no one has ever questioned it ! Why do we love switch statements ? We've had switch statements in other programming languages since the dawn of time and if not, it was definitely long before I was born. Therefore reasons to use switch statements over if and if else statements are also clear and kind of indisputable. It is preferable to use switch , if you can agree with following statements in your programming language and of course specific situation you are in: Code is easier to read and therefore it is easier to understand and maintain Code is easier to debug Code is faster to execute
Solutions, implementation tips, benchmarks and news from the world of Salesforce especially focused on technical side of things.