dropWhile
definition
abstract def dropWhile(pred: (A) ⇒ Boolean): Repr
Drops longest prefix of elements that satisfy a predicate.
Note: might return different results for different runs, unless the underlying collection type is ordered.
pred
The predicate used to test elements.
returns
the longest suffix of this general collection whose first element does not satisfy the predicate p.demo
val donuts: Seq[String] = Seq("Plain Donut 1", "Plain Donut 2", "Strawberry Donut", "Plain Donut 3", "Glazed Donut")
// declare a predicate function to be passed-through to the dropWhile function
val dropElementsPredicate: (String) => Boolean = (donutName) => donutName.charAt(0) == 'P'
val dropDonuts = donuts.dropWhile(dropElementsPredicate)Last updated