Scala List dropWhile() method with example Last Updated : 26 Jul, 2019 Improve Improve Like Article Like Save Share Report The dropWhile() method is utilized to drops the longest prefix of elements that satisfies the stated condition. Method Definition: def dropWhile(p: (A) => Boolean): List[A] Return Type: It returns all the elements of the list except the dropped ones. Example #1: // Scala program of dropWhile() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(1, 3, 5, 4, 2) // Applying dropWhile method val res = m1.dropWhile(x=>{x % 2 != 0}) // Displays output println(res) } } Output: List(4, 2) Example #2: // Scala program of dropWhile() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(3, 6, 5, 4, 2) // Applying dropWhile method val res = m1.dropWhile(x=>{x % 3 == 0}) // Displays output println(res) } } Output: List(5, 4, 2) Like Article Suggest improvement Previous Scala List mkString() method with example Next Scala List addString() method with example Share your thoughts in the comments Add Your Comment Please Login to comment...