Does Scala have a library method to wrap nullable return values in an Option?

scala

Solution

scala> Option(null)
res0: Option[Null] = None

scala> Option(1)
res1: Option[Int] = Some(1)

Problem

Something like ``` def option[T](v: T): Option[T] = if (v == null) None else Some(v) ``` I'm perfectly happy defining this utility method myself, but just wondered if it already exists somewhere.

Original source