flatMap

trait Collection[A] {
  def flatMap(f: (A) => Collection[B]): Collection[B]
}

flatMap creates a collection by applying the function f to each element and using the resulting subelements as elements of the new collection.