So will come back again in this lesson you're going to talk about a raise in swift on arrays and see
if they're actually rather simple.
So this jump into ex-coach and in a year I'm going to start a new project I'm going to make it a command
line tool.
I'm going to call it arrays in the swift and then in my arrays in swift and then I clear all of these.
I don't need not I don't need that number say why are my array.
And you could either directly define it by adding literal items to it say hello and then saying oh well
that would become your array.
Or you could actually choose it specifically to be an array of let's say a string.
So then I know that this array is on a string.
So let's call it a string array.
Now if I want to see an object from it simply I'm going to say print.
And what do I want to print.
I want to print the string array object at index 0 for instance.
And that would simply print our head or in this case for me.
Right.
And once he shows up here.
Hello and then I could obviously do things such as having one array I could say strings or a dot of
pens.
And why would I want to append is I.
Oh yes.
And then of course I could get things such as the strings array that count.
So that's kind of preinstall value for me.
So if I go ahead and run you should be seeing 0 1 2 3 elements and it perfect.
You could remove objects you could say a string array remove at and I'm going to remove object that
is sitting in the first one.
And now if I go ahead and say print the strings array we can see that.
Now we don't have hello if you should only have a word on us perfect the way that we expect it to happen.
So while you can use a swift array such as this one which are they can be annotated that they have a
specifically a strings in them.
You could also use Enas arrays if you want.
So if you want you can say there my are a..
Array.
That's going to be a..
Array.
And then it's going to be an end a separate part in it.
And then I have all the familiar stuff such as any with objects which I'm going to say is going to be
hello.
And then also going to be ward.
There are some times that I prefer to use as arrays as opposed to us with there is or Leader or eyes.
And we'll get to see them as the time comes.
I've been actually in a few sections from now and I do a little game for you guys.
I started with arrays then then I showed you how MSRA could actually benefit us in you know some of
the stuff such as finding a certain item or removing a particular object in those kind of things and
acetates might be a little bit easier to use.
Even though arrays do all of those things but you know anisotropies might offer a little you know simpler
ways it is simpler for me because that is for us because we know Objective-C a little bit better now.
But in saying that arrays do almost absolutely everything that you know and SRI's do as well and they
do actually beyond on one that they want to show you.
Is this trend our index of say war.
So I'm going to say preens and it is called the strings array index.
I'm going to look for index of what I'm looking for index of is actually wall.
So let's see what that one prints for me.
So now when it runs it should say men because a world is not anywhere in there.
So let's see why.
That's because I actually made a mistake and that's because here we remove the first object.
So our it doesn't actually have a word.
So in a sort of word if I look for.
Hello.
I could actually see this a lot easier.
Outsprint thing that it is an optional value zero.
Now I'm much better off doing this thing is using an if.
Let.
So I'm going to say if let let's call it our index.
He is going to be disvalue if this thing actually exists.
He flips the data then Prince Freyne stands on.
Hello he is X and then you remember that we are going to do this thing.
We're going to say it's at index.
And of course in the else we could print.
It's not here or something to that effect.
So let's run this
on now.
It says hello is at zero and if I were searching for iOS it would say US is in one in this situation.
And so on and so forth.
So that's about that you can use arrays are simply eyes you know declaring your array and getting its
rotators explicit type if you want your arrays to have all different types and you don't want to explicitly
mention that you can just drop this by its entirety or you could just say.
And so this array could accept any kind of value let's say including a numeric integer value and then
in here one of the challenges that we'll face is in here that you cannot invoke a method such as index
for arrays that they don't have type.
The type is any to remedy a situation like this.
We could either adopt an equitable you know protocol that we'll talk about sometime in the future or
we could use something like an S or a which doesn't have the type just like how and so is an objective
c don't have to have types.
They don't have have type in here either.
So with that in mind that's about it.
Arrays are adding or removing counting finding certain object and explicitly telling them their type
or making sure that they are essentially typeless or they are any.
And with that in mind let's move on to our next level.
Next lesson that you're going to talk about dictionaries.