Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Episode 2 conditional flows & loops

939 views

Published on

Conditional Flow in Salesforce and types of Loop. Episode 2 details are here - http://pathtocode.com/salesforce/developer/episode-2-conditional-statements-loops/

Published in: Education
  • Be the first to comment

  • Be the first to like this

Episode 2 conditional flows & loops

  1. 1. Path to Code Begin Your Salesforce Coding Adventure
  2. 2. Episode 2 Conditional Statements, Ternary Operators, Loops
  3. 3. Enterprise Solutions Architect Global Salesforce Community Speaker 4x Salesforce Certifications Jigar Shah
  4. 4. Agenda • Need for Control Flow Statements • Control Flow Statements • Iteration using Loops • When to use List vs Set vs Hash map? • Trailhead Modules • Q&A
  5. 5. Some Housekeeping Rules… • Mute your mic • Keep adding questions in Zoom Q&A Window • No questions are silly! • Questions will be answered in the last 15 mins of this session
  6. 6. Need for Control Flow Statements Conditional Execution Comparison of Data Computation of Data Traversal over Data Elements in Collections Repeated Execution
  7. 7. Control Flow Statements Control Flow Statements govern the behavior of your Apex code Types of Control Flow Statements • Conditional • Iterative
  8. 8. Conditional Statements
  9. 9. Conditional Statements in Apex 1. If Else… 2. Switch Statements 3. Ternary Operators
  10. 10. If Else Statements if(Boolean Condition){ //Code Block } else{ //Code Block } if(Boolean Condition1){ //Code Block } else if(Boolean Condition2){ //Code Block } else if(Boolean Condition3){ //Code Block } else{ //Code Block (Optional Default Condition) }
  11. 11. Operators Fuel your decisions!
  12. 12. Operators
  13. 13. Ternary Operators • Uses ? : (Boolean Condition) ? Value if True : Value if False • Left Associative • Short-hand for if-then-else statements.
  14. 14. Switch Statements switch on expression{ when value1, value2{ //Code Block } when value3{ //Code Block } when value4{ //Code Block } } • Match 1 of the several available values • Switch expression can have – String, Sobject, Enum, Integer, Long, Methods • Apex types are Nullable
  15. 15. Iterative Statements - Loops
  16. 16. Iterative Statements 5 Types of Procedural Loops in Apex  Do {Code Block} While (Boolean Exit Condition)  While (Boolean Exit Condition)  For  For (Initialization; Boolean Exit Condition; Increment) {Code Block}  For (Variable : Array or Set) {Code Block}  For (Variable : [Inline SOQL Query]) {Code Block}
  17. 17. Choosing List Vs Set Vs Map • List • Map • Set
  18. 18. Resources  Control Flow Statements  Expressions & Operators  Switch Statements  Loops
  19. 19. Trailhead Modules Platform Development Basics Apex Basics & Database Developer Console Basics
  20. 20. Q & A
  21. 21. Thank You
  22. 22. Subscribe

×