11. Hash

11.14 Using select

Here we have a hash of people with their house number.

houses = {
    "John" => 507,
    "Sally" => 239,
    "Adam" => 786,
    "Nancy" => 324,
    "Kelly" => 788

Our task is to find all the people who live in house whose number is more than 500.

We can use select to do this job.

We will build a condition which will return true if the condition is met.

In this case the condition is the the house number should be more than 500.