1 00:00:00,950 --> 00:00:03,990 So when we last left off, we had printed out our list. 2 00:00:05,850 --> 00:00:07,220 And let's go ahead and run this again. 3 00:00:08,440 --> 00:00:11,670 The item is Milk and we only want one thing of milk. 4 00:00:11,670 --> 00:00:15,090 Okay, let's clean up how this looks a little bit. 5 00:00:15,090 --> 00:00:19,550 First, since we're sort of duplicating code here, 6 00:00:19,550 --> 00:00:24,150 by printing out a separator, let's go ahead and make a method out of that. 7 00:00:24,150 --> 00:00:31,030 And we'll call that method output_separator. 8 00:00:31,030 --> 00:00:34,980 You know what? Let's call it print_separator. 9 00:00:34,980 --> 00:00:39,170 And we'll give it an argument of the character that we wanna print. 10 00:00:39,170 --> 00:00:43,586 And we can go ahead and give this a default value of a dash. 11 00:00:46,667 --> 00:00:52,464 And all this method is going to do is print that character 80 times. 12 00:00:55,084 --> 00:00:56,764 Now let's go ahead and 13 00:00:56,764 --> 00:01:01,284 replace the printing of the separator with the method name. 14 00:01:06,244 --> 00:01:07,583 Okay. 15 00:01:09,944 --> 00:01:13,890 Clear my screen here and run this again. 16 00:01:13,890 --> 00:01:16,330 You know what I can take out the list here. 17 00:01:16,330 --> 00:01:20,300 I can take out the list inspection since we're printing it on our own now. 18 00:01:21,660 --> 00:01:26,670 This name is Groceries, and the item that we're adding is Milk. 19 00:01:26,670 --> 00:01:27,820 And 1. 20 00:01:27,820 --> 00:01:31,740 Okay, now we have a separator. 21 00:01:31,740 --> 00:01:34,280 But let's go ahead and clean this up even a little bit more. 22 00:01:35,410 --> 00:01:37,410 So now let's go ahead and indent each line here. 23 00:01:38,470 --> 00:01:43,190 So we'll print a tab character Inside of this list and 24 00:01:43,190 --> 00:01:46,580 the item's name and then another plus. 25 00:01:46,580 --> 00:01:50,100 And let's say we'll do three tab characters here and the quantity. 26 00:01:51,150 --> 00:01:55,290 Now I want quantity to be all on the same line so 27 00:01:55,290 --> 00:02:00,690 I'm going to add another plus and take out that put statement. 28 00:02:03,930 --> 00:02:06,680 And this will create one big string and 29 00:02:06,680 --> 00:02:09,480 send it in as an argument to the puts method. 30 00:02:09,480 --> 00:02:16,056 Let me clear my screen here, click in to the console and run this again. 31 00:02:20,457 --> 00:02:22,230 Okay, this is looking a little bit better. 32 00:02:22,230 --> 00:02:27,490 We've got our grocery list, and our item of milk, and our quantity of one. 33 00:02:28,610 --> 00:02:32,330 Let's go ahead and say that we want to add another list item. 34 00:02:34,270 --> 00:02:35,880 Print my screen and run this again. 35 00:02:35,880 --> 00:02:38,060 List name is Groceries. 36 00:02:38,060 --> 00:02:40,860 The item is Milk, and we only want one. 37 00:02:40,860 --> 00:02:43,900 Bread, we're gonna say we want two loaves of bread. 38 00:02:43,900 --> 00:02:44,740 And that looks good. 39 00:02:44,740 --> 00:02:48,970 We've got a separator in between each of the items. 40 00:02:48,970 --> 00:02:49,500 But you know what? 41 00:02:49,500 --> 00:02:53,800 Let's go ahead and print the separator at the end of all the list items instead. 42 00:02:53,800 --> 00:02:57,817 I think that'll look just a little bit better. 43 00:03:00,137 --> 00:03:03,277 And now let's go ahead and just add another item to the list. 44 00:03:05,798 --> 00:03:11,930 And in fact before we print the list, I'm just going to print here's your list. 45 00:03:13,430 --> 00:03:14,280 And a new line. 46 00:03:16,170 --> 00:03:19,260 In fact let's go ahead and add another message and say great. 47 00:03:20,490 --> 00:03:23,010 Add some items to your list. 48 00:03:25,400 --> 00:03:28,700 Now let me clear my screen here, there's gonna be more output so 49 00:03:28,700 --> 00:03:35,130 I'm gonna make this a little bit bigger and type ruby shopping_list.rb. 50 00:03:35,130 --> 00:03:37,490 This name is Groceries Great. 51 00:03:37,490 --> 00:03:40,010 Let's add some items to the list. 52 00:03:40,010 --> 00:03:42,730 Milk, we only need one. 53 00:03:42,730 --> 00:03:45,740 Bread, two loaves of bread. 54 00:03:45,740 --> 00:03:48,920 Eggs, let's get three dozen eggs because we're really hungry. 55 00:03:50,030 --> 00:03:55,780 All right, and here is our grocery list with our three different items and 56 00:03:55,780 --> 00:03:57,279 the corresponding quantities. 57 00:03:58,470 --> 00:04:02,580 In this course, we've learned about how arrays and hashes work, and 58 00:04:02,580 --> 00:04:05,300 have even learned some simple iteration. 59 00:04:05,300 --> 00:04:07,060 Don't stop now, though. 60 00:04:07,060 --> 00:04:10,060 Make sure to practice these concepts on your own, and 61 00:04:10,060 --> 00:04:12,960 practice by building your own programs. 62 00:04:12,960 --> 00:04:16,330 If you need inspiration, check out the extra credit. 63 00:04:16,330 --> 00:04:16,950 Happy coding.