What is the best practice to perform such an operation? Add T
to Vector[T]
if T
is Some[T]
otherwise do nothing. This ugly thing works
val v: Vector[Int] = Vector(1, 2, 3) ++ Some(5).toSeq
But converting an Option to a Seq is far from intuitive. I was thinking of defining an implicit for Vector
and Option
but I was wondering if there is something out of the box I can use.
I would expect for something like this to work
val v: Vector[Int] = Vector(1, 2, 3) :+ Some(5)
But apparently Option
is NOT Traversable
.