Scala Mutable SortedMap dropWhile() method with example
Last Updated :
04 May, 2020
The dropWhile() method is utilized to delete the elements until the stated condition is satisfied.
Method Definition: def dropWhile(p: ((A, B)) => Boolean): SortedMap[A, B]
Return Type: It returns the longest suffix of elements of the stated SortedMap whose first element does not satisfies the predicate p.
Example #1:
import scala.collection.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 2 )
val result = m 1 .dropWhile(z => false )
println(result)
}
}
|
Output:
Map(cs -> 2, for -> 3, geeks -> 5)
Example #2:
import scala.collection.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 2 )
val result = m 1 .dropWhile(z => true )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...