1 00:00:01,000 --> 00:00:05,500 In this video we're going to discuss why we care about tuples and when we might use them. 2 00:00:05,560 --> 00:00:10,480 I'll be honest with you I am not a huge fan of tuples and I don't think you're going to really be using 3 00:00:10,480 --> 00:00:12,920 them in a very regular basis with typescript. 4 00:00:12,940 --> 00:00:17,920 There are a couple exceptions most notably I think that if you're ever working with a CSP file any one 5 00:00:17,920 --> 00:00:23,800 represents say a single row you might reach out to a tuple will actually work at the CSP file later 6 00:00:23,800 --> 00:00:27,580 on inside this course and so you'll see a great example of that in action. 7 00:00:27,580 --> 00:00:32,410 So let me tell you exactly why I don't think you're going to be using tuples that often at the bottom 8 00:00:32,410 --> 00:00:38,320 this file on when you declare a new variable called Car specs like so and I'm going to assign it some 9 00:00:38,320 --> 00:00:44,440 data that has a real important meaning around a car like some specifications around a car. 10 00:00:44,440 --> 00:00:51,400 So I'm going to assign it a tuple of four hundred three fifty like so I'll make sure that I annotate 11 00:00:51,400 --> 00:00:56,290 the type on here to make sure it's really clear that this is a tuple so it's a number and a number like 12 00:00:56,290 --> 00:00:57,230 so. 13 00:00:57,430 --> 00:00:57,660 Okay. 14 00:00:57,670 --> 00:01:01,230 So here's the question what do these numbers mean to you. 15 00:01:01,240 --> 00:01:05,110 I mean looking at this line of code right here in isolation what do those numbers mean. 16 00:01:05,110 --> 00:01:07,520 Clearly it has something to do with these specs around a car. 17 00:01:07,630 --> 00:01:10,210 But what is the purpose of these numbers. 18 00:01:10,210 --> 00:01:14,980 Well for us as engineers I don't think that we can really look at this line of code and understand what 19 00:01:14,980 --> 00:01:16,190 is going on here. 20 00:01:16,210 --> 00:01:17,650 We know that there are two values. 21 00:01:17,680 --> 00:01:23,500 We know that they are numbers but that's pretty much it so let's try writing out that same type of data 22 00:01:23,500 --> 00:01:26,600 structure right here but instead as an object. 23 00:01:26,630 --> 00:01:32,620 So if I write out a very similar variable right here maybe I'll call it car stats this time I'm gonna 24 00:01:32,620 --> 00:01:38,230 make it an object and because it's an object this time I have to add in a key and a value. 25 00:01:38,230 --> 00:01:45,370 So for the value 400 I'm going to give a key of horsepower horsepower. 26 00:01:45,380 --> 00:01:46,460 There we go. 27 00:01:46,520 --> 00:01:51,830 And then for the three three five four I'll put in weight like so. 28 00:01:52,040 --> 00:01:52,330 All right. 29 00:01:52,360 --> 00:01:53,980 So what am I trying to illustrate here. 30 00:01:53,980 --> 00:01:59,860 Well if we use a tuple to represent some meaningful data it's really hard for you and I's engineers 31 00:01:59,860 --> 00:02:06,070 to look at this value right here and understand what we are trying to say however in an object format 32 00:02:06,070 --> 00:02:08,640 right here because we are forced to put in a key. 33 00:02:08,740 --> 00:02:11,480 It is immediately obvious what we are working with. 34 00:02:11,500 --> 00:02:15,760 I can look at this object right here and understand 0 horsepower 400. 35 00:02:15,850 --> 00:02:16,810 Got it. 36 00:02:16,810 --> 00:02:21,790 And then for weights This is the weight of maybe a car in pounds three thousand three hundred fifty 37 00:02:21,790 --> 00:02:23,200 four pounds. 38 00:02:23,230 --> 00:02:29,140 So when we make use of an object to model a record it's really clear what we were working with at one 39 00:02:29,200 --> 00:02:34,240 glance but when we are working at that table much harder to understand exactly what is going on at a 40 00:02:34,240 --> 00:02:41,330 glance so honestly I think that in general any time we want to model a record or record it in our application 41 00:02:41,330 --> 00:02:46,430 somehow we're going to stick with a javascript convention of reaching for an object as opposed to a 42 00:02:46,450 --> 00:02:47,540 temple. 43 00:02:47,580 --> 00:02:52,220 Now like I said there are some corner cases where we might want to use this in some types of applications 44 00:02:52,250 --> 00:02:55,160 and we will see an example of it later on INSIDE THIS COURSE. 45 00:02:55,160 --> 00:02:59,760 Actually it's one of the first two or three applications we're going to work on. 46 00:02:59,890 --> 00:03:00,120 All right. 47 00:03:00,150 --> 00:03:04,270 So I'm sorry to teach you about troubles and then say hey we're never going to use them but nonetheless 48 00:03:04,330 --> 00:03:11,020 it is a feature of typescript that is very prominently featured in the official documentation. 49 00:03:11,020 --> 00:03:15,890 So I just want to make sure you have at least a passing idea of what these type of things are all about. 50 00:03:15,900 --> 00:03:17,140 So let's take a quick pause right here. 51 00:03:17,140 --> 00:03:19,540 We're going to move on to our next topic in the next video.