title: Scala - finding a specific tuple in a list
body: <p>Let's say we have this list of tuples:</p>
  <pre><code>val data = List(('a', List(1, 0)), ('b', List(1, 1)), ('c', List(0)))
  </code></pre>
  <p>The list has this signature:</p>
  <pre><code>List[(Char, List[Int])]
  </code></pre>
  <p>My task is to get the &quot;List[Int]&quot; element from a tuple inside &quot;data&quot; whose key is, for instance, letter &quot;b&quot;. If I implement a method like &quot;findIntList(data, 'b')&quot;, then I expect List(1, 1) as a result. I have tried the following approaches:</p>
  <ol>
  <li><code>data.foreach { elem =&gt; if (elem._1 == char) return elem._2 }</code></li>
  <li><code>data.find(x=&gt; x._1 == ch)</code></li>
  <li><code>for (elem &lt;- data) yield elem match {case (x, y: List[Bit]) =&gt; if (x == char) y}</code></li>
  <li><code>for (x &lt;- data) yield if (x._1 == char) x._2</code></li>
  </ol>
  <p>With all the approaches (except Approach 1, where I employ an explicit &quot;return&quot;), I get either a <code>List[Option]</code> or <code>List[Any]</code> and I don't know how to extract the &quot;<code>List[Int]</code>&quot; out of it.</p>