1

I thought this would work to extract a List[String], but no. (anmKey is Option[String])

run(query[Anm].map(_.anmKey).flatMap(_))
user3416742
  • 168
  • 1
  • 1
  • 7

1 Answers1

1

To get rid of the options, and the nones, use flatten

scala> List(Some("string1"), None, Some("string2")).flatten
val res0: List[String] = List(string1, string2)

Alternatively, if you want to keep the options but remove the nones, you can use filter.

scala> List(Some("string1"), None, Some("string2")).filter(_.isDefined)
val res1: List[Option[String]] = List(Some(string1), Some(string2))
sbrk
  • 1,338
  • 1
  • 17
  • 25