Scala 3, Programming Scala.
empty, we must wrap the returned sequence in an Option. If any row is empty, we’ll return None for the whole thing: def firstColumn[T](xss: Seq[Seq[T]]): Option[Seq[T]] = optional: xss.map(_.headOption.?) The concision is very nice, but it requires some unpacking to understand what’s happening.