I have a code segment something like this:
def test() : Seq[Int] =
List("A", "B", "C") collect {
case "A" => 1
case "B" => 2
//case _ => println(_)
}
Now I would like to print specific values (just for debugging) on the output without adding any elements to the resulting collection. If I uncomment the commented line, Scala infers the value of the expression to Seq[Any]
, which is completely understandable.
Anybody got any hints how to do this? Thanks in advance!
flatMap
collect
/flatten