1 00:00:00,930 --> 00:00:05,100 In this video we're going to follow up on a raise by discussing a very similar data structure called 2 00:00:05,130 --> 00:00:08,630 a tunnel and you'll sometimes also hear this pronounced as tuple. 3 00:00:08,640 --> 00:00:11,520 Totally up to you either tuple or topple. 4 00:00:11,520 --> 00:00:13,010 Either way you want to do it. 5 00:00:13,010 --> 00:00:16,350 So as usual definition examples and so on. 6 00:00:16,350 --> 00:00:16,520 All right. 7 00:00:16,530 --> 00:00:18,320 So first off quick definition. 8 00:00:18,320 --> 00:00:23,490 So when we're working with a tuple or a couple we have something that looks very similar to an array 9 00:00:23,610 --> 00:00:25,020 very very similar. 10 00:00:25,020 --> 00:00:29,790 But the big difference here is that we are going to have every element inside of this array looking 11 00:00:29,790 --> 00:00:33,990 thing represent one specific property about some record. 12 00:00:33,990 --> 00:00:39,060 So whereas in array tells us a bunch of different records or organizes a collection of different records 13 00:00:39,510 --> 00:00:46,120 a couple usually contains multiple different properties to describe one single thing and as a follow 14 00:00:46,120 --> 00:00:46,570 up to that. 15 00:00:46,570 --> 00:00:52,110 Usually inside of a couple we will mix and match many different types of data inside there. 16 00:00:52,180 --> 00:00:54,260 Let's take a look at a quick example. 17 00:00:54,310 --> 00:00:54,630 All right. 18 00:00:54,640 --> 00:00:59,200 I want you to imagine that we've got some object like the one you see right here and the goal this object 19 00:00:59,230 --> 00:01:04,450 is to represent a drink like in this case soda or pop whatever you want or refer to it as. 20 00:01:04,570 --> 00:01:10,240 So maybe inside this object we have a color property that is a string of brown carbonated that is a 21 00:01:10,240 --> 00:01:16,300 billion of true and sugar that is meant to represent the sugar content of the soda in grams. 22 00:01:16,300 --> 00:01:17,790 So that will be a number here. 23 00:01:17,800 --> 00:01:23,480 So as you might guess this would represent maybe like Coca-Cola or Pepsi or something like that. 24 00:01:23,630 --> 00:01:28,870 So representing a drink or a soda with an object like this I think makes a lot of sense if you're coming 25 00:01:28,870 --> 00:01:31,030 particularly from a javascript background. 26 00:01:31,270 --> 00:01:37,210 We've got one object to represent one drink and this object has some properties that describe what is 27 00:01:37,210 --> 00:01:40,600 going on with this singular drink now just for fun. 28 00:01:40,660 --> 00:01:45,340 I want to take this object right here and I just want to try to represent it with a slightly different 29 00:01:45,340 --> 00:01:46,700 data structure. 30 00:01:46,750 --> 00:01:50,550 Let's try to represent this object with an array instead. 31 00:01:50,620 --> 00:01:52,180 So how can we do that. 32 00:01:52,180 --> 00:01:55,300 Well maybe we would say that we would take each these values. 33 00:01:55,300 --> 00:02:04,260 So like Brown true and then 40 and stick them into this array like so. 34 00:02:04,310 --> 00:02:10,560 So now we have a slightly different looking data structure that still represents a drink and turning 35 00:02:10,560 --> 00:02:12,280 this into this array right here. 36 00:02:12,360 --> 00:02:14,430 We have lost a little bit of information. 37 00:02:14,640 --> 00:02:19,650 In other words you and I as developers can very easily look at a object declaration like this right 38 00:02:19,650 --> 00:02:20,130 here. 39 00:02:20,250 --> 00:02:22,220 And very quickly understand OK. 40 00:02:22,230 --> 00:02:28,620 The colors Brown carbonate is true and sugar is 40 when we start to represent this object as an array 41 00:02:28,680 --> 00:02:31,820 we've lost those different property labels on here. 42 00:02:31,890 --> 00:02:37,500 And so you and I as developers would have to memorize the fact that the first element inside this array 43 00:02:37,770 --> 00:02:40,210 is supposed to be a string representing the color. 44 00:02:40,380 --> 00:02:45,630 The second element is supposed to be a boolean representing whether or not the drink is carbonated. 45 00:02:45,630 --> 00:02:50,200 And then the third element inside there is a number representing these sugar content. 46 00:02:50,310 --> 00:02:55,530 So the big difference between represent this as an object and something that looks like an array is 47 00:02:55,530 --> 00:03:02,150 really just that loss of information in these labels no longer is our code really self labeling. 48 00:03:02,160 --> 00:03:06,320 Instead we have to kind of memorize the order of properties inside of here. 49 00:03:06,340 --> 00:03:08,590 So this is exactly what a table is. 50 00:03:08,680 --> 00:03:14,890 We have what looks like an array and we put in our property values into that array in a very specific 51 00:03:14,920 --> 00:03:15,360 order. 52 00:03:16,060 --> 00:03:18,220 So the ordering part is really critical. 53 00:03:18,220 --> 00:03:23,770 If we start to arbitrarily swap around elements inside of here we are no longer going to understand 54 00:03:23,830 --> 00:03:26,660 which different value represents which property. 55 00:03:27,520 --> 00:03:32,500 So if you and I have memorized like as developers that this array is always supposed to tell us the 56 00:03:32,500 --> 00:03:39,100 color then the carbonation and then the sugar content and we swapped some elements inside of here and 57 00:03:39,100 --> 00:03:40,620 we don't have those labels. 58 00:03:40,630 --> 00:03:46,720 Now this is kind of a meaningless record because we're now trying to indicate that our color is 40 carbonation 59 00:03:46,720 --> 00:03:49,200 is true in sugar content is brown. 60 00:03:49,360 --> 00:03:55,700 So when we work at the table that we have a fixed series of elements or a fixed order I should say all 61 00:03:55,700 --> 00:03:55,870 right. 62 00:03:55,880 --> 00:03:59,570 Now let's take a quick pause right here we can come back the next section get some more examples around 63 00:03:59,570 --> 00:04:02,420 tuples and start to write out some code around them. 64 00:04:02,420 --> 00:04:04,740 So quick pause and I'll see you in just a minute.