1 00:00:00,510 --> 00:00:09,780 Hello and welcome to this lecture on this lecture harbi explaining to you how to use each method. 2 00:00:09,850 --> 00:00:13,410 Him the Ruby programming language. 3 00:00:13,410 --> 00:00:16,900 What does the heat method do. 4 00:00:16,920 --> 00:00:29,550 It may it is basically used to access Harry objets laws will use to access it up just in a hash every 5 00:00:29,610 --> 00:00:39,240 Harry and has Ruby is basically an object and each of them have their own built in methods and they 6 00:00:39,270 --> 00:00:48,610 each method also is built in to but they erase and also the hash objects. 7 00:00:48,780 --> 00:00:56,040 Each method take theme to arguments an element and a block. 8 00:00:56,490 --> 00:00:59,090 So this is an example here. 9 00:00:59,400 --> 00:01:12,160 We've got a variable there or C T and we are using the each method to access the members of their Arey. 10 00:01:12,420 --> 00:01:21,750 So they say it is the salary and we are using the Puts to display each city and then we end the statements. 11 00:01:21,750 --> 00:01:28,630 I'm going to show you how this work using the ruby interactive tool. 12 00:01:28,980 --> 00:01:37,000 I have caught the ruby interactive tool open so I'm going to start by creatine. 13 00:01:37,110 --> 00:01:41,380 Hillary I'm going to create a record 15th 14 00:01:43,750 --> 00:01:53,530 and I'm going to give it the value I'm going to set it free and I include the objets for Arey. 15 00:01:54,090 --> 00:01:56,340 Ah so London. 16 00:01:59,060 --> 00:02:01,030 Now the first sitting. 17 00:02:02,900 --> 00:02:04,500 I'm next sitting. 18 00:02:05,080 --> 00:02:06,900 I'll say New York. 19 00:02:13,470 --> 00:02:18,380 Next city I'll see Frankfurt. 20 00:02:22,190 --> 00:02:24,070 Now close me. 21 00:02:24,090 --> 00:02:26,260 Hurry. 22 00:02:26,310 --> 00:02:28,610 So we now have Hillary. 23 00:02:29,010 --> 00:02:38,430 So now I want to implement the eight method s c c d quoll in the array. 24 00:02:38,430 --> 00:02:44,750 Now the seat is dupped. 25 00:02:44,940 --> 00:02:58,620 I'm trying to access each object in that Harry Santo's see teeth dot each and then they do and in between 26 00:02:58,620 --> 00:03:05,900 the pipes the pipes is just a symbol next to the Z key inbetween the pipe. 27 00:03:05,940 --> 00:03:10,440 Passing the element are passing in city. 28 00:03:13,500 --> 00:03:15,250 Press Enter. 29 00:03:15,580 --> 00:03:27,480 This time I want to display some text on the screen so I use the PUDs typing sitting. 30 00:03:27,540 --> 00:03:35,860 So each year each method will get each member that Harry displayed on the screen. 31 00:03:36,440 --> 00:03:38,220 And I need to end the statement. 32 00:03:38,220 --> 00:03:48,700 So Ruby Ruby can action the request a presenter as he can see each member of the Arey has been listed. 33 00:03:48,780 --> 00:03:55,750 So the each method is basically used to access members off an array. 34 00:03:56,070 --> 00:03:59,240 You can use this bit a hash as well. 35 00:03:59,640 --> 00:04:09,130 In the example I chose some illustrate it the element contained within the pipe which is in this case 36 00:04:09,130 --> 00:04:13,870 the city is similar to a place holder. 37 00:04:14,070 --> 00:04:25,430 So whatever you put in the pipes is used in the block to represent each element of an array in turn. 38 00:04:25,950 --> 00:04:36,210 The block is the line of code that is executed on each of the three items and if handled the element 39 00:04:36,330 --> 00:04:37,950 to process. 40 00:04:37,950 --> 00:04:40,320 So that's how it works. 41 00:04:40,320 --> 00:04:44,440 So the process will work the same way for he has. 42 00:04:44,610 --> 00:04:53,390 So you can get it to return the key and a value a fit for this next hour. 43 00:04:53,430 --> 00:04:54,650 Thanks for watching. 44 00:04:54,700 --> 00:04:55,650 Hmm bye for now.