Adding Variables Into Strings

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
€85.91
List Price:  €120.29
You save:  €34.37
£74.62
List Price:  £104.47
You save:  £29.85
CA$137.73
List Price:  CA$192.84
You save:  CA$55.10
A$153.57
List Price:  A$215
You save:  A$61.43
S$128.82
List Price:  S$180.36
You save:  S$51.53
HK$780.45
List Price:  HK$1,092.67
You save:  HK$312.21
CHF 80.49
List Price:  CHF 112.69
You save:  CHF 32.20
NOK kr1,000.46
List Price:  NOK kr1,400.69
You save:  NOK kr400.22
DKK kr641.23
List Price:  DKK kr897.75
You save:  DKK kr256.51
NZ$170.72
List Price:  NZ$239.01
You save:  NZ$68.29
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,175.01
List Price:  ৳17,045.50
You save:  ৳4,870.49
₹8,813.10
List Price:  ₹12,338.70
You save:  ₹3,525.59
RM423.25
List Price:  RM592.57
You save:  RM169.32
₦153,210.67
List Price:  ₦214,501.07
You save:  ₦61,290.40
₨28,383.20
List Price:  ₨39,737.62
You save:  ₨11,354.41
฿3,239.07
List Price:  ฿4,534.83
You save:  ฿1,295.76
₺4,114.87
List Price:  ₺5,760.99
You save:  ₺1,646.11
B$544.45
List Price:  B$762.25
You save:  B$217.80
R1,772.09
List Price:  R2,481
You save:  R708.90
Лв167.53
List Price:  Лв234.55
You save:  Лв67.01
₩139,447.22
List Price:  ₩195,231.68
You save:  ₩55,784.46
₪339.07
List Price:  ₪474.71
You save:  ₪135.64
₱5,746.67
List Price:  ₱8,045.57
You save:  ₱2,298.90
¥14,854.89
List Price:  ¥20,797.44
You save:  ¥5,942.55
MX$1,875.93
List Price:  MX$2,626.38
You save:  MX$750.44
QR365.13
List Price:  QR511.19
You save:  QR146.06
P1,436.54
List Price:  P2,011.22
You save:  P574.67
KSh12,918.70
List Price:  KSh18,086.70
You save:  KSh5,168
E£4,849.46
List Price:  E£6,789.44
You save:  E£1,939.98
ብር14,206.62
List Price:  ብር19,889.84
You save:  ብር5,683.21
Kz91,186.39
List Price:  Kz127,664.59
You save:  Kz36,478.20
CLP$96,808.31
List Price:  CLP$135,535.51
You save:  CLP$38,727.20
CN¥713
List Price:  CN¥998.24
You save:  CN¥285.23
RD$6,292.09
List Price:  RD$8,809.17
You save:  RD$2,517.08
DA12,984.71
List Price:  DA18,179.12
You save:  DA5,194.40
FJ$226.17
List Price:  FJ$316.65
You save:  FJ$90.48
Q767.42
List Price:  Q1,074.42
You save:  Q307
GY$20,938.25
List Price:  GY$29,314.40
You save:  GY$8,376.14
ISK kr12,336.76
List Price:  ISK kr17,271.96
You save:  ISK kr4,935.20
DH900.12
List Price:  DH1,260.21
You save:  DH360.08
L1,661.93
List Price:  L2,326.78
You save:  L664.84
ден5,257.29
List Price:  ден7,360.41
You save:  ден2,103.12
MOP$804.11
List Price:  MOP$1,125.79
You save:  MOP$321.67
N$1,759.85
List Price:  N$2,463.86
You save:  N$704.01
C$3,684.68
List Price:  C$5,158.70
You save:  C$1,474.01
रु14,123.84
List Price:  रु19,773.94
You save:  रु5,650.10
S/353.62
List Price:  S/495.09
You save:  S/141.46
K423.91
List Price:  K593.49
You save:  K169.58
SAR375.19
List Price:  SAR525.28
You save:  SAR150.09
ZK2,365.54
List Price:  ZK3,311.85
You save:  ZK946.31
L436.41
List Price:  L611
You save:  L174.58
Kč2,103.13
List Price:  Kč2,944.47
You save:  Kč841.33
Ft34,037.82
List Price:  Ft47,654.32
You save:  Ft13,616.49
SEK kr945.38
List Price:  SEK kr1,323.57
You save:  SEK kr378.19
ARS$137,659.46
List Price:  ARS$192,728.75
You save:  ARS$55,069.29
Bs691.82
List Price:  Bs968.58
You save:  Bs276.75
COP$404,511.35
List Price:  COP$566,332.08
You save:  COP$161,820.72
₡50,618.68
List Price:  ₡70,868.18
You save:  ₡20,249.49
L2,621.40
List Price:  L3,670.07
You save:  L1,048.66
₲723,189.07
List Price:  ₲1,012,493.63
You save:  ₲289,304.56
$U4,001.03
List Price:  $U5,601.60
You save:  $U1,600.57
zł366.60
List Price:  zł513.26
You save:  zł146.65
Already have an account? Log In

Transcript

Hello, and welcome to the sixth tutorial swift basics series. And in this part we will be looking at how to add variables into string. Swift provides the ability to include various variables within a string is community. So for example, if you have a whole variable that stores the user's name, when they log on to an application, you can greet them saying their username, like Hello, and then their name. So for Bob, you could say hello Bob, or whatever name they've recorded in the application. It is extremely simple to do they just open up a project.

So let's get rid of this second. So for var, I equals on the put button, and if I want to print that out and do print, and then I can specify the variable name so if I run it printed, I could do multiple print lines, but their print line so there'll be on a separate line soccer we do Hello Batman, hello, and then Batman. But if you want to add variable within a string you do like this quotation marks. Hello. And then the place you want to put a variable do backslash as you can see it's coming up with errors because it's no longer recognizing these two quotation marks in open close bracket. And then inside of here, you put your variable and now I run it and now it says hello Batman.

And you can do this several times. Comma backslash by Hello Batman Batman. It is that simple to add variables into strings. That's it for this tutorial. In the next tutorial we're going to look at how swift handles arrays. If you have any question feel free to message us or support us on our system.

Cody Kay. The email will be in the room. scription you can comment on this video directly message us. All the required source code will be in the description by link. And as usual, 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.