Break Statement

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€86.15
List Price:  €120.62
You save:  €34.46
£75.19
List Price:  £105.27
You save:  £30.08
CA$136.98
List Price:  CA$191.79
You save:  CA$54.80
A$142.01
List Price:  A$198.83
You save:  A$56.81
S$127.77
List Price:  S$178.89
You save:  S$51.11
HK$780.78
List Price:  HK$1,093.13
You save:  HK$312.34
CHF 78.58
List Price:  CHF 110.01
You save:  CHF 31.43
NOK kr966.97
List Price:  NOK kr1,353.80
You save:  NOK kr386.82
DKK kr643.64
List Price:  DKK kr901.12
You save:  DKK kr257.48
NZ$169.78
List Price:  NZ$237.69
You save:  NZ$67.91
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,257.82
List Price:  ৳17,161.44
You save:  ৳4,903.61
₹9,207.49
List Price:  ₹12,890.86
You save:  ₹3,683.36
RM394.56
List Price:  RM552.40
You save:  RM157.84
₦137,150.28
List Price:  ₦192,015.88
You save:  ₦54,865.60
₨28,030.81
List Price:  ₨39,244.26
You save:  ₨11,213.44
฿3,169.53
List Price:  ฿4,437.47
You save:  ฿1,267.94
₺4,397.52
List Price:  ₺6,156.70
You save:  ₺1,759.18
B$518.59
List Price:  B$726.05
You save:  B$207.46
R1,630.35
List Price:  R2,282.55
You save:  R652.20
Лв168.51
List Price:  Лв235.93
You save:  Лв67.41
₩147,756.71
List Price:  ₩206,865.31
You save:  ₩59,108.59
₪310.18
List Price:  ₪434.26
You save:  ₪124.08
₱5,853.29
List Price:  ₱8,194.84
You save:  ₱2,341.55
¥15,765.70
List Price:  ¥22,072.61
You save:  ¥6,306.91
MX$1,747.93
List Price:  MX$2,447.18
You save:  MX$699.24
QR366.86
List Price:  QR513.62
You save:  QR146.76
P1,328.09
List Price:  P1,859.38
You save:  P531.29
KSh12,903.70
List Price:  KSh18,065.70
You save:  KSh5,162
E£4,996.50
List Price:  E£6,995.30
You save:  E£1,998.80
ብር15,702.76
List Price:  ብር21,984.50
You save:  ብር6,281.73
Kz91,195.12
List Price:  Kz127,676.82
You save:  Kz36,481.70
CLP$88,306.16
List Price:  CLP$123,632.16
You save:  CLP$35,326
CN¥689.95
List Price:  CN¥965.95
You save:  CN¥276
RD$6,024.06
List Price:  RD$8,433.93
You save:  RD$2,409.86
DA13,080.35
List Price:  DA18,313.02
You save:  DA5,232.66
FJ$220.92
List Price:  FJ$309.30
You save:  FJ$88.38
Q769.43
List Price:  Q1,077.23
You save:  Q307.80
GY$20,986.45
List Price:  GY$29,381.87
You save:  GY$8,395.42
ISK kr12,379.76
List Price:  ISK kr17,332.16
You save:  ISK kr4,952.40
DH924.08
List Price:  DH1,293.75
You save:  DH369.67
L1,721.44
List Price:  L2,410.09
You save:  L688.64
ден5,288.14
List Price:  ден7,403.61
You save:  ден2,115.46
MOP$808.30
List Price:  MOP$1,131.66
You save:  MOP$323.35
N$1,611.11
List Price:  N$2,255.62
You save:  N$644.50
C$3,691.52
List Price:  C$5,168.27
You save:  C$1,476.75
रु14,682.35
List Price:  रु20,555.88
You save:  रु5,873.53
S/337.21
List Price:  S/472.11
You save:  S/134.89
K431.67
List Price:  K604.35
You save:  K172.68
SAR375.25
List Price:  SAR525.37
You save:  SAR150.11
ZK1,916.03
List Price:  ZK2,682.53
You save:  ZK766.49
L441.35
List Price:  L617.91
You save:  L176.56
Kč2,096.87
List Price:  Kč2,935.70
You save:  Kč838.83
Ft33,199.21
List Price:  Ft46,480.23
You save:  Ft13,281.01
SEK kr924.20
List Price:  SEK kr1,293.92
You save:  SEK kr369.72
ARS$139,387.86
List Price:  ARS$195,148.59
You save:  ARS$55,760.72
Bs694.61
List Price:  Bs972.49
You save:  Bs277.87
COP$379,337.72
List Price:  COP$531,087.98
You save:  COP$151,750.26
₡47,211.02
List Price:  ₡66,097.32
You save:  ₡18,886.29
L2,654.65
List Price:  L3,716.62
You save:  L1,061.96
₲647,542.85
List Price:  ₲906,585.90
You save:  ₲259,043.04
$U3,841.23
List Price:  $U5,377.88
You save:  $U1,536.64
zł368.20
List Price:  zł515.50
You save:  zł147.29
Already have an account? Log In

Transcript

Hello, welcome to the 14th tutorial for the swift basic series. And in this tutorial we are looking at the break statement. The break time allows you to exit a loop prematurely, perhaps you're in a loop, and you can have a certain condition check. If that condition is met, you just want to exit that loop. And the brainstem allows you to do that. So let's open up our project and show you how to implement the break statement.

It is really simple. So what we're just going to quickly create a an array of high scores. So we can just loop through them at 734 504 in here and zero i less than four plus, plus going to do is print ln co backslash i plus one so that just tells us what number it is colon backslash now we have printed the school. High Schools never gonna record the scores. So perhaps if the score not fair play in a country where there if the score is 34 for example, we want to break out for whatever reason so you can just do if high schools high the word equals you fall to break out you just simply put a break in it literally that simple. You can put a semicolon you don't have to put a semicolon to choice runner and look we got Scott one 100 Score 287 but because score free, the one at index two is 34 it equals that and then it breaks so if we were to go to the no 60 which isn't in the high score array, it will print out everything for you back for the four it will break out there for you won't even print there so just ended prematurely at the point of it breaking.

That's it for this tutorial. In the next tutorial, we're going to look at the continuous statement testing and basically allows you to skip any iteration of the loop. If you have any questions feel free to message us or support us on our system code. Okay, the email will be in the description you can comment on this video directly messaged us via YouTube or the recordings full source code will also be in the description. Thanks for watching and have a nice day.

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.