title: How do I get an item in a list that matches a certain condition?
body: <p>I have the following sample code :</p>
  
  <pre><code>package models
  
  import java.util.concurrent.atomic.AtomicInteger
  import scala.collection.mutable.ArrayBuffer
  
  case class Task(id: Int, label: String)
  
  object Task {
  
    private val buffer = new ArrayBuffer[Task]
    private val incrementer = new AtomicInteger()
  
    def all(): List[Task] = buffer.toList
  
    def create(label: String): Int = {
      val newId = incrementer.incrementAndGet()
      buffer += new Task(newId, label)
      newId
    }
  
    def delete(id: Int): Boolean = {
  
      // TODO : add code
  
    }
  }
  </code></pre>
  
  <p>In method <code>delete</code> I need to find a <code>Task</code> that has <code>id</code> equal to the parameter <code>id</code> and if one is found I need to remove it from the collection and return true from the method. Otherwise (if none is found) I should just return false.</p>
  
  <p>I know how to do this in an imperative language such as C# or Java but Scala stumps me..</p>
  
  <p>PS : The code is strictly used to understand the language and the platform, it sucks too much to be pushed in production. Don't worry.</p>