In this video we're going to follow up on a raise by discussing a very similar data structure called
a tunnel and you'll sometimes also hear this pronounced as tuple.
Totally up to you either tuple or topple.
Either way you want to do it.
So as usual definition examples and so on.
All right.
So first off quick definition.
So when we're working with a tuple or a couple we have something that looks very similar to an array
very very similar.
But the big difference here is that we are going to have every element inside of this array looking
thing represent one specific property about some record.
So whereas in array tells us a bunch of different records or organizes a collection of different records
a couple usually contains multiple different properties to describe one single thing and as a follow
up to that.
Usually inside of a couple we will mix and match many different types of data inside there.
Let's take a look at a quick example.
All right.
I want you to imagine that we've got some object like the one you see right here and the goal this object
is to represent a drink like in this case soda or pop whatever you want or refer to it as.
So maybe inside this object we have a color property that is a string of brown carbonated that is a
billion of true and sugar that is meant to represent the sugar content of the soda in grams.
So that will be a number here.
So as you might guess this would represent maybe like Coca-Cola or Pepsi or something like that.
So representing a drink or a soda with an object like this I think makes a lot of sense if you're coming
particularly from a javascript background.
We've got one object to represent one drink and this object has some properties that describe what is
going on with this singular drink now just for fun.
I want to take this object right here and I just want to try to represent it with a slightly different
data structure.
Let's try to represent this object with an array instead.
So how can we do that.
Well maybe we would say that we would take each these values.
So like Brown true and then 40 and stick them into this array like so.
So now we have a slightly different looking data structure that still represents a drink and turning
this into this array right here.
We have lost a little bit of information.
In other words you and I as developers can very easily look at a object declaration like this right
here.
And very quickly understand OK.
The colors Brown carbonate is true and sugar is 40 when we start to represent this object as an array
we've lost those different property labels on here.
And so you and I as developers would have to memorize the fact that the first element inside this array
is supposed to be a string representing the color.
The second element is supposed to be a boolean representing whether or not the drink is carbonated.
And then the third element inside there is a number representing these sugar content.
So the big difference between represent this as an object and something that looks like an array is
really just that loss of information in these labels no longer is our code really self labeling.
Instead we have to kind of memorize the order of properties inside of here.
So this is exactly what a table is.
We have what looks like an array and we put in our property values into that array in a very specific
order.
So the ordering part is really critical.
If we start to arbitrarily swap around elements inside of here we are no longer going to understand
which different value represents which property.
So if you and I have memorized like as developers that this array is always supposed to tell us the
color then the carbonation and then the sugar content and we swapped some elements inside of here and
we don't have those labels.
Now this is kind of a meaningless record because we're now trying to indicate that our color is 40 carbonation
is true in sugar content is brown.
So when we work at the table that we have a fixed series of elements or a fixed order I should say all
right.
Now let's take a quick pause right here we can come back the next section get some more examples around
tuples and start to write out some code around them.
So quick pause and I'll see you in just a minute.