Aloha Trailblazers,
In this post, I'm sharing the code snippet for Coding with Confidence: The Fun Way to Learn Salesforce Apex tutorial series part 25 and above:// * Control Flow statements: Used to control the flow of code execution. You can skip a block of code or have a block of code executed repeatedly. These statements include: if-else (conditional) statements, switch statements and loops // * if - else / Conditional Statements if(<Boolean>) { } else { } // * if Statement Integer num = 10; System.debug('Start...'); if(num > 50) { System.debug('num is greater than 50'); } System.debug('End...'); // * if Statement with else Integer num = 100; System.debug('Start...'); if(num > 50) { System.debug('num is greater than 50'); System.debug('num is greater than 50'); System.debug('num is greater than 50'); } else { System.debug('num is not greater than 50 and is: ' + num); System.debug('num is not greater than 50 and is: ' + num); System.debug('num is not greater than 50 and is: ' + num); } System.debug('End...'); // * Repeated if else statements, if else chaining Integer num = 50; System.debug('Start...'); if(num > 50) { System.debug('num is greater than 50'); } else if(num < 50) { System.debug('num is less than 50'); } else if(num == 50) { System.debug('num is equal to 50'); } else { System.debug('num is null'); } System.debug('End...'); // * nested if else enum SalesforceRelease { SPRING, SUMMER, WINTER } Integer age = 10; SalesforceRelease currentRelease = SalesforceRelease.WINTER; if(currentRelease == SalesforceRelease.SPRING) { if(age >= 18) { System.debug('Richard will drive a bike.'); } else { System.debug('Richard will board a bus.'); } } else if(currentRelease == SalesforceRelease.SUMMER) { if(age >= 18) { System.debug('Richard will drive a car.'); } else { System.debug('Richard will board a metro.'); } } else if(currentRelease == SalesforceRelease.WINTER) { if(age >= 18) { System.debug('Richard will drive a truck.'); } else { System.debug('Richard will stay home.'); } }