So well come back again in business and we're going to talk about the strings in a swift quote initialise
them how we could append them to each other how we could modify them so on and so forth is going to
be one to our easier lessons.
So let's get us started.
I'm going to go to school.
I'm going to start a new art maybe a playground just so that you know we alternate them.
I think the last one was in our last home with a command line so there's three things.
Playground
so and right off the bat.
We have on a string which really you know helps us faith in understanding that everything is you know
as we would expect it.
Our string of that type of string explicitly told the compiler is going to be a string.
The one thing that we have an s in swift compared to Objective-C is a multi-line a string.
So I could say multi line a string.
They gain the type of string that's going to be I'm going to add three quotation marks and then between
these I can write whatever I want to write like this is line 1 1 and this is a line 2.
And so on and so forth.
So if you have a long line of string on like what's behind the objective see that you had to actually
add for the slashes and ends for returns.
You can just simply add them between three quotation marks which really simplifies a lot of our work.
Now these things are leaderless which are like this can be initialized either this way or I could say
verify my ascii are again of the type.
The string is going to be empty.
All I could say there are there.
The art is going to be a string and that's essentially initialising good as a string without any content
essentially being an empty one.
Another thing that is kind of Nuwan also interesting in swift is that you can actually concatenate the
strings or you can append them to each other just using the operators.
So I could go ahead and say there are let's call it first a C R and that's going to be hello and then
I'm going to have r r let's call it second the C R and that's going to be a space war.
And then I could say where the rest are just going to be first the string plus Second the string and
then if I go ahead and say print on a string.
Obviously Arvi should expect to see Hello space walk
and you know we got art in the compiler and it was in the consummately of hello world which is really
a lot easier than doing what we would do in Objective C because first the our hand a string and then
have the other one second a C R and then close it with a square brackets.
As things are obviously a much broader topic and I'm going to show you a few more things.
One of them is comparing strings.
So in the past you have to use things such as If one string is equal to another string and that's you
know would essentially call a function.
And then we had to you know get a boolean value from that in see if we do this thing a lot easier we
can simply say if the first the string is second string and that's about that I can just go ahead and
say print the same math for instance else I could say prints are not the same.
So comparing a string is a lot easier or instructive as well.
So let's read on this.
We should see the not the same.
Perfect.
And one last thing I want to show you is going to lead.
First thing I think we saw this when we were working in the contour floors and the work and therefore
loops.
I'm harder than I say let my longest string to be a string of course answers.
Hello.
This is Iowas both Khyam and now I can't say for any ideas of the type character in my long string.
I can go ahead and say print in for instance.
So that would essentially go through every letter of the character for me which in here every letter
of the string.
Sorry it says escheat double or comma a space.
So on and so forth.
There's a lot more that you know we can do with the strings.
I think this covers the basics of it.
Initialising then concatenating them as well as you know removing pieces from them you can just rewrite
the pieces back to each other and of course comparing them against each other or going through a character
is the first thing that could be useful from time to time.
I haven't the link with this lesson.
I was really a commander.
You guys have a look at it.
There are things such as getting a substring reading only a range of characters.
The reason I'm not going to do it is because we haven't seen those meters yet such as you know finding
Oranje.
But I would recommend that you guys have a quick read through it so at least you know these things are
possible.
And then down the track when we get to know how to use them they want to be completely new topics for
you.
So with that in mind let's move on.