1
00:00:00,540 --> 00:00:11,790
Hello and welcome to this lecture or anything to be explaining what hashes are what is a hat in some

2
00:00:11,790 --> 00:00:17,150
programming languages it is referred to as a dictionary.

3
00:00:17,250 --> 00:00:20,240
Ruby Ruby just refers to it as the house.

4
00:00:20,350 --> 00:00:22,530
He has basically Ruby.

5
00:00:22,550 --> 00:00:28,980
He is an on ordered object index collection of objects.

6
00:00:29,310 --> 00:00:40,660
So in comparison two and three and three is an ordered collection of objects while a house is not ordered.

7
00:00:41,010 --> 00:00:49,330
So the objet in house you cannot guarantee the order they will be.

8
00:00:49,340 --> 00:00:59,940
Also while in an array you access the value base on the indexed with a hash you reference it find the

9
00:01:00,060 --> 00:01:00,810
object.

10
00:01:00,810 --> 00:01:03,470
We will have a key value.

11
00:01:04,170 --> 00:01:09,310
So the key will have a corresponding value.

12
00:01:09,540 --> 00:01:16,320
So the key difference between an array and a Hash is that Flurry is an ordered collection and it has

13
00:01:16,440 --> 00:01:19,880
is an ordered collect.

14
00:01:20,250 --> 00:01:25,860
You can reference he has via the objet in the key value pairs.

15
00:01:26,040 --> 00:01:33,850
This will make more sense when we go on to create an example hash shortly.

16
00:01:34,090 --> 00:01:36,530
Hash is identified.

17
00:01:36,730 --> 00:01:45,580
My curly braces who when you create a hash you have to have include curlee process so you create a hash.

18
00:01:45,600 --> 00:01:48,480
Basically the same way you would create a ring.

19
00:01:48,480 --> 00:01:50,240
So you start with a name.

20
00:01:50,400 --> 00:01:58,770
So I'm going to create a hash and I'm going to call it cars or car.

21
00:01:58,770 --> 00:02:06,960
Make a car single up and set it to the airport to and then need the curly braces so you need the curly

22
00:02:06,960 --> 00:02:09,870
braces in order to pull the plug.

23
00:02:09,860 --> 00:02:18,040
It's inside the house so we have to define the key and then we defined a value.

24
00:02:18,060 --> 00:02:25,300
So the key the first key unguents defined here is going to be the model of the car.

25
00:02:26,220 --> 00:02:37,540
So type in model and enclose that in quotes and then you do an equal to and greater than sign.

26
00:02:38,000 --> 00:02:42,640
When you do that now you have to give it a value.

27
00:02:42,900 --> 00:02:45,920
So we've given it the we've got the key.

28
00:02:45,990 --> 00:02:48,810
Now we need to add the value.

29
00:02:49,080 --> 00:02:51,700
So the value surrounded input.

30
00:02:52,020 --> 00:02:54,930
So my value here is going to be porsh

31
00:02:57,640 --> 00:03:05,030
P R C H E porsh so that is one value.

32
00:03:05,040 --> 00:03:08,170
That's the value of one object and do a comma.

33
00:03:08,170 --> 00:03:13,130
If you want to add more say I want to add a column.

34
00:03:13,560 --> 00:03:14,190
So you do.

35
00:03:14,190 --> 00:03:28,920
Quotes followed by the word caller and then an equal to and then a greater than sign and then the value

36
00:03:28,980 --> 00:03:30,930
of the caller.

37
00:03:31,860 --> 00:03:33,400
So I see.

38
00:03:33,930 --> 00:03:41,940
And you can go on until you know you exhausted the list but this is just an example.

39
00:03:42,210 --> 00:03:48,920
So once you done it does poorly are the curly braces to close.

40
00:03:48,930 --> 00:03:59,040
They have a few press enter it shows you that I've created a hash and this is a key for the first object

41
00:03:59,450 --> 00:04:02,130
and that is a value second object.

42
00:04:02,130 --> 00:04:05,310
This is the key that is of value.

43
00:04:05,310 --> 00:04:07,700
This is all a means by key value.

44
00:04:07,870 --> 00:04:15,530
P appears in pairs but they each value is object value object value here.

45
00:04:15,540 --> 00:04:23,240
This object key this referred to as the key and it has a corresponding value.

46
00:04:24,240 --> 00:04:31,570
What an array wait to access the octave in said array used the index with the hash.

47
00:04:31,590 --> 00:04:33,820
You can use the key.

48
00:04:34,170 --> 00:04:44,400
So if I type in the name of the hash which is car and then in square bracket I just type in in quotes

49
00:04:44,460 --> 00:04:52,890
the name of what I'm looking for so I see a model include a square bracket and actually return posh

50
00:04:53,490 --> 00:04:57,930
he can see is giving me the value of push I've typed in the key.

51
00:04:57,930 --> 00:04:59,510
It's giving me value.

52
00:04:59,780 --> 00:05:08,610
So in comparison with I raise you use the objects the key in the object to access the value outside

53
00:05:08,690 --> 00:05:12,700
access the values inside the hash.

54
00:05:12,740 --> 00:05:16,700
You can also access the key if you want it to access the key.

55
00:05:16,700 --> 00:05:22,340
For example I can typing car dot key

56
00:05:25,550 --> 00:05:31,950
and then just to type in the name of the key.

57
00:05:34,210 --> 00:05:34,690
People

58
00:05:38,410 --> 00:05:43,550
see it and press enter.

59
00:05:43,720 --> 00:05:48,730
That is giving me a model so you can also do it this way.

60
00:05:49,040 --> 00:05:55,960
All right so that's basically the kid defend it in an RV and it has to if you want something that you're

61
00:05:55,960 --> 00:06:01,720
not you don't care what order then you can use the hash if you want something that is structured to

62
00:06:01,720 --> 00:06:03,210
want a certain order.

63
00:06:03,580 --> 00:06:05,540
Then Harry is the way to go.

64
00:06:05,590 --> 00:06:08,060
So there's a lot you can do with hashes.

65
00:06:08,290 --> 00:06:14,820
It works similarly to areas where you can manipulate them just as you would agree as well.

66
00:06:14,930 --> 00:06:18,110
So that's it for this brief introduction to.

67
00:06:18,130 --> 00:06:19,120
He has.

68
00:06:19,120 --> 00:06:24,100
You can read more about it on the ruby documentation.

69
00:06:24,130 --> 00:06:25,650
Many thanks for watching.

70
00:06:25,730 --> 00:06:26,790
Bye for now.
