1 00:00:00,440 --> 00:00:05,800 Similarly, to hash keys, Ruby provides us methods for working with hash values. 2 00:00:07,150 --> 00:00:09,930 Let's take a look of some of those now using WorkSpaces. 3 00:00:10,960 --> 00:00:14,220 Okay, so I've just created a new ruby WorkSpace here and 4 00:00:14,220 --> 00:00:15,910 here we are in the console. 5 00:00:15,910 --> 00:00:20,039 Let's go ahead and launch an irb session and start working with hash values. 6 00:00:21,810 --> 00:00:24,080 So let's create a hash to work with. 7 00:00:24,080 --> 00:00:29,475 The item here is gonna be "Bread", quantity of 1 and 8 00:00:29,475 --> 00:00:35,260 the brand is still gonna be "Treehouse Bread Company". 9 00:00:37,340 --> 00:00:39,280 All right, so here is a hash to work with. 10 00:00:40,280 --> 00:00:46,260 Now just like the method for looking at all the keys was called hash dot keys, 11 00:00:46,260 --> 00:00:50,380 we have a similar method to look at all the values called values. 12 00:00:51,510 --> 00:00:56,260 And that will return an array of all of the different values inside of the hash. 13 00:00:57,500 --> 00:01:03,650 And again how we asked the hash if it had a key, and passed in an argument, 14 00:01:03,650 --> 00:01:06,680 we can do the same thing to see if it has a value. 15 00:01:06,680 --> 00:01:09,721 So we could say hash.has_value, and 16 00:01:09,721 --> 00:01:15,710 then pass in a value it does not have the value "brand" because that's a key, but 17 00:01:15,710 --> 00:01:21,813 let's see if it has a value for the number one which is the quantity and it does. 18 00:01:25,046 --> 00:01:30,100 And we can also use the method value and pass in an argument. 19 00:01:30,100 --> 00:01:34,520 It's pretty much the exact same thing, an alias under a different name. 20 00:01:36,110 --> 00:01:39,700 If we wanted to get a couple values back from the hash, 21 00:01:39,700 --> 00:01:45,370 we could use the values_at method and pass in the keys that we want. 22 00:01:45,370 --> 00:01:48,850 We'll say we want "item" and "quantity", and 23 00:01:48,850 --> 00:01:53,450 that will return an array of the values for the keys that we passed in. 24 00:01:54,730 --> 00:01:59,760 Try practicing with hashes and hash values on your own now using WorkSpaces.