title: Ruby use find to loop through an array and return the matching value
body: <p>I am trying to loop through an array using find to find and return a specific id.
  This is my structure:</p>
  
  <pre><code>{
    "employees": [
      {
        "emp_id": "1",
        "tutorials": [
          {
            "id": "test1"
          },
          {
            "id": "test2"
          },
          {
            "id": "test3"
          },
          {
            "id": "test4"
          },
          {
            "id": "test5"
          }
        ]
      }
    ]
   }
  </code></pre>
  
  <p>So basically I am trying to see if the above structure contains a tutorial id of 'test3' and return it.(i.e return 'test3' in this case)</p>
  
  <p>I can get the desired result using a combination of map and find like this:</p>
  
  <pre><code> my_tutorial = employees.map { |employee|
    employee.tutorials.find { |tutorial|
      tutorial.id == 'test3'
    }
  }.first
  
  my_tutorial
  </code></pre>
  
  <p>But I want to know if there is a better way using find . I tried the following but it returns the ruby object instead of the id.</p>
  
  <pre><code> employees.find { |employee|
    employee.tutorials.find { |tutorial|
      tutorial.id == 'test3'
  
    }
  }
  </code></pre>