title: Convert a List into an Option if it is populated
body: <p>I have a method that should convert a list to an <code>Option</code> of an object, or <code>None</code> if the list is empty.</p>
  
  <pre><code>def listToOption(myList: List[Foo]): Option[Bar] = {
    if(myList.nonEmpty) Some(Bar(myList))
    else None
  }
  
  case class Bar(fooList: List[Foo]) {}
  </code></pre>
  
  <p>For some reason, my solution feels rather inelegant, and not the Scala way. It seems I should be able to use a method on <code>List</code> to do this sort of thing, but I can't wrap my head around it.</p>
  
  <p>Is there a more Scala-like way to do this?</p>