You can also use zip, but it will wrap the underlying elements in Seq from nested pairs that are not easy to smooth out for reuse.
Some(1) zip Some(2) == List((1,2)) Some(2) zip Some(2) zip Some(3) == List(((1,2),3)) Some(1) zip Some(2) zip None == List()
or you can do something like this
val options = Seq(Some(p1), Some(p2), Some(p3),None) val parameters = options.flatten if(parameters.length == options.length) do something with parameters
source share