scala> Seq("abc", null).mkString(" ")
res0: String = abc null
but I want to get "abc" only
Is there a scala way to skip nulls?
scala> val seq = Seq("abc", null, "def")
seq: Seq[String] = List(abc, null, def)
scala> seq.flatMap(Option[String]).mkString(" ")
res0: String = abc def
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With