Sprinkle some scalaz :
import scalaz._; import Scalaz._
And setting:
scala> val optList = some(List(1, 2, 3, 4) optList: Option[List[Int]] = Some(List(1, 2, 3, 4)) scala> val list = List(5, 6, 7) list: List[Int] = List(5, 6, 7)
Then I can do:
scala> ~optList ::: list res0: List[Int] = List(1, 2, 3, 4, 5, 6, 7)
Basically ~ is a unary method bound to Option[A] , where for type A there is zero. Null for the list of course Nil
source share