Control flow execution with Switch statement

Salesforce Development Using Apex Control flow execution with Switch statement
8 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€47.51
List Price:  €66.52
You save:  €19
£39.57
List Price:  £55.40
You save:  £15.83
CA$69.83
List Price:  CA$97.77
You save:  CA$27.93
A$76.76
List Price:  A$107.48
You save:  A$30.71
S$67.19
List Price:  S$94.07
You save:  S$26.88
HK$389.07
List Price:  HK$544.73
You save:  HK$155.66
CHF 44.17
List Price:  CHF 61.85
You save:  CHF 17.67
NOK kr552.55
List Price:  NOK kr773.61
You save:  NOK kr221.06
DKK kr354.40
List Price:  DKK kr496.19
You save:  DKK kr141.78
NZ$85.21
List Price:  NZ$119.31
You save:  NZ$34.09
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳5,978.91
List Price:  ৳8,370.95
You save:  ৳2,392.04
₹4,225.77
List Price:  ₹5,916.42
You save:  ₹1,690.64
RM223.20
List Price:  RM312.50
You save:  RM89.30
₦84,012.69
List Price:  ₦117,624.49
You save:  ₦33,611.80
₨13,908.54
List Price:  ₨19,473.08
You save:  ₨5,564.53
฿1,733.10
List Price:  ฿2,426.48
You save:  ฿693.38
₺1,727.24
List Price:  ₺2,418.28
You save:  ₺691.03
B$290.46
List Price:  B$406.67
You save:  B$116.21
R906.09
List Price:  R1,268.60
You save:  R362.51
Лв92.91
List Price:  Лв130.09
You save:  Лв37.17
₩70,046.43
List Price:  ₩98,070.61
You save:  ₩28,024.17
₪186.68
List Price:  ₪261.37
You save:  ₪74.69
₱2,952.60
List Price:  ₱4,133.88
You save:  ₱1,181.28
¥7,718.58
List Price:  ¥10,806.63
You save:  ¥3,088.05
MX$1,017.02
List Price:  MX$1,423.91
You save:  MX$406.89
QR182.44
List Price:  QR255.44
You save:  QR72.99
P683.49
List Price:  P956.94
You save:  P273.45
KSh6,461.20
List Price:  KSh9,046.20
You save:  KSh2,585
E£2,482.03
List Price:  E£3,475.04
You save:  E£993.01
ብር6,237.86
List Price:  ብር8,733.50
You save:  ብር2,495.64
Kz45,607.24
List Price:  Kz63,853.79
You save:  Kz18,246.54
CLP$48,681.26
List Price:  CLP$68,157.66
You save:  CLP$19,476.40
CN¥362.01
List Price:  CN¥506.84
You save:  CN¥144.83
RD$3,017.61
List Price:  RD$4,224.90
You save:  RD$1,207.28
DA6,678.15
List Price:  DA9,349.94
You save:  DA2,671.79
FJ$113.48
List Price:  FJ$158.89
You save:  FJ$45.40
Q386.23
List Price:  Q540.76
You save:  Q154.52
GY$10,467.47
List Price:  GY$14,655.30
You save:  GY$4,187.82
ISK kr6,913.61
List Price:  ISK kr9,679.61
You save:  ISK kr2,766
DH499.81
List Price:  DH699.78
You save:  DH199.96
L910.32
List Price:  L1,274.52
You save:  L364.20
ден2,923.74
List Price:  ден4,093.48
You save:  ден1,169.73
MOP$401.12
List Price:  MOP$561.60
You save:  MOP$160.48
N$907.46
List Price:  N$1,270.52
You save:  N$363.05
C$1,841.10
List Price:  C$2,577.69
You save:  C$736.58
रु6,753.23
List Price:  रु9,455.06
You save:  रु2,701.83
S/189.86
List Price:  S/265.82
You save:  S/75.96
K201.41
List Price:  K281.99
You save:  K80.58
SAR187.67
List Price:  SAR262.75
You save:  SAR75.08
ZK1,384.62
List Price:  ZK1,938.58
You save:  ZK553.95
L236.44
List Price:  L331.04
You save:  L94.59
Kč1,203.80
List Price:  Kč1,685.42
You save:  Kč481.62
Ft19,537.53
List Price:  Ft27,354.11
You save:  Ft7,816.57
SEK kr551.39
List Price:  SEK kr771.99
You save:  SEK kr220.60
ARS$50,126.56
List Price:  ARS$70,181.20
You save:  ARS$20,054.63
Bs346.46
List Price:  Bs485.08
You save:  Bs138.61
COP$220,634.58
List Price:  COP$308,906.07
You save:  COP$88,271.48
₡25,407.49
List Price:  ₡35,572.52
You save:  ₡10,165.02
L1,264.30
List Price:  L1,770.13
You save:  L505.82
₲391,827.47
List Price:  ₲548,589.81
You save:  ₲156,762.34
$U2,138.81
List Price:  $U2,994.50
You save:  $U855.69
zł206.57
List Price:  zł289.22
You save:  zł82.64
Already have an account? Log In

Transcript

Also I'll give you a very basic example of switch statements okay? CMI, how have you failed same way we have something called switch statements the similar thing, but to the syntactical different but they both do the same activities Okay. So now what is switch statement happening? So, now we have like how economists and that is present do these things else do that thing, same thing we can achieve using a switch statement also switch also in one control flow, do some statements Okay. What do we do the thing that really will right switch on expression, okay. Then we see when when no one then good.

These are the ways thick are the next 1.2 Okay, then a Google something is, if nothing is satisfying, then point is, then decode the statements. It's like this. Let's say a file, try to let me go to my neighbor's window. I'm just going to execute one small piece of code. Let's consider I have integer number equal to 20. They're gonna bring in a seven jumper.

Okay? And I want to see how my switch statement works. Simply or they can do I not switch, okay? on number. Okay, then I'm writing. Like, what would you be eating if pneumonia sent on to like that?

So I'm just going to any expression you can, you can check Okay, number lesson don't deal with any kind of expression you can do also on this taking the same number directly. So now, you can use when, Okay, number is 10. Okay. I want In this system to go debug I mean say okay when the number is 20 I want to open a standard gave me certainty okay? Let's utilize MRP nothing is satisfying in one part I can say finals. I can create systems or debug I'm not satisfied.

Lengthy statement also, I can write and the moment when I read the statement the utterance is like if he fails, but it's wasted when we call. So it takes what is the value of numbers? Okay, now take number is 20 okay then I'll come inside I will see where I have blocked 20 if I can no I will come to 20 And I like to put this one as everything said you were everything we will discuss it on the statement. If I go on a cold water, I'll get it as output. If you go here, see I'm inside 20 Let's consider I gave valuers 21 not matching to 2010 not matching 220. I'll come to this with this one.

Okay. So now let's go to it and see where I'm going. The only I can I'm not satisfied. So if you see I have a note for 10. Then I'll come number 11 trying to check, okay, it's 10. Then Not a word of Allah, whatever calculating here it's matching to which law.

Okay, is 10 that means I'm inserting. I'll come here. And I'll see. I get way into the statement. That means, out of so many statements, I control only to execute this One other we are skipping. So I can control the flow of execution by using events by using switch also, the switch will do the syntactically right switch on what explicit.

So I have taken the variable here. And again, the value matches do these things. Miners miners, so ask me any clarification you need on this. See these basic things, what we're discussing will right in the program, when you do program, you will see the real time implementation which is happening, but I'm just educating What are these things? When we we will Yeah, scenario based personal right program. And that moment, if I explain this, if you may not understand that, so I'm just making the path to be clear, and we'll write 30 and implement some programs.

When you're working on Yeah. You're saying I the switch will only happen when exactly that value is met. Whereas if we'll be when we did less than or it will, it will be more than Loop it'll keep checking to leave satisfied. That kind of condition I know I will not say it is like a loop because lie low p will go for indicating again and again. But this will not again, do it again, this is only one time in the code. If satisfied, then I like to go inside this even not satisfied.

And I'll go out of this out of this blog, low pointer calm where we're going to look at rest when you go to low electrical again and again till the time I'm satisfying the condition. Okay, and just maybe it's a silly question to VCs. Are you in the console right now? Because I can't understand what screen are you in when you are wearing anonymous Google Chrome? Is that a different app? No, no, no, no.

Endorsee first of all, don't worry. It may be any silicone screen or difficult code. You can feel free you wish we were learning. Okay. With you showed us if maybe anything. Nobody's going to say no But you can ask anything even you can ask it What is this icon that also you can ask?

Yeah. So even go to the Salesforce then you can go to my developer console here it is. Yeah. Yes Then in this digital console, what I can do we can write a class which you can save on the system or we may have to load or anything in the system to set and also I may write a piece of code which I do not want to serve anywhere, but I want to execute only so that is nothing but my anonymous window. Okay. Yes, in my face.

Yes. Yeah. So gentle. Oh, could you please go to this syntax? Oh, yes, we want to see once Yeah, switch on the expression and is the vendor so what expression evaluating the guy Oh okay. Okay, first in the switch on expression first you will evaluate this value if this value matches to any of this loop means any of the statement that that only will again correct.

So but in general we will lose no more right. And basically we lose equals more very we don't use like truly to speak in my happiness and we don't have a three statement my article so in my office hours nice cat man we don't hurt before but try things before one and a half years or two years. So this cat man introduced me in the I think it was not there before, but this was you know, swimming in the river there. But we don't have it. It's a recent let's see there. So we may use what depends so we are comfortable with the principles, but you should know so I explained what it is.

Yeah, okay. Good. Perfect. So I hope you all are clear till now correct if working the same way. Let's see one more basic concept which you call looping okay. So my problems usually I can control by email or switch and also look and when is a no What is it?

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.