The partition method takes a predicate function as its parameter and will use it to return two collections: one collection with elements that satisfied the predicate function and another collection with elements that did not match the predicate function.
def partition(p: (A) ⇒ Boolean): (Repr, Repr)
demo
val donutNamesAndPrices: Seq[Any] = Seq("Plain Donut", 1.5, "Strawberry Donut", 2.0, "Glazed Donut", 2.5)
val namesAndPrices: (Seq[Any], Seq[Any]) = donutNamesAndPrices.partition {
case name: String => true
case price: Double => false
}
// access the donut prices sequence from namesAndPrices
val prices = namesAndPrices._2