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.
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.
scala> Option(null)
res0: Option[Null] = None
scala> Option(1)
res1: Option[Int] = Some(1)