Scala Mutable SortedSet forall() method Last Updated : 26 Mar, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Scala mutable collections, SortedSet forall() method is utilized to check if the given predicate satisfies all the elements of the SortedSet or not. Method Definition: def forall(p: (A) => Boolean): Boolean Return Type: It returns true if the stated predicate holds true for all the elements of the SortedSet else it returns false. Example #1: Scala // Scala program of forall() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(13, 7, 12, 9, 21) // Applying forall method val result = s1.forall(y => {y % 3 == 0}) // Displays output println(result) } } Output: false Example #2: Scala // Scala program of forall() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(15, 12, 21, 30) // Applying forall method val result = s1.forall(y => {y % 3 == 0}) // Displays output println(result) } } Output: true Comment More infoAdvertise with us Next Article Scala mutable SortedSet &() method S Shivam_k Follow Improve Article Tags : Scala Scala Scala-Method Scala mutable-sortedset Similar Reads Scala Mutable SortedSet foreach() method In Scala mutable collections, SortedSet foreach() method is utilized to apply the given function to all the elements of the SortedSet. Method Definition: def foreach(f: (A) => Unit): Unit Return Type: It returns all the elements of the SortedSet after applying the given function to each of them. 1 min read Scala Mutable SortedSet -() method In Scala mutable collections, SortedSet -() method is utilized to creates a new SortedSet with a given element removed from the SortedSet. Method Definition: def -(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with a given element removed from the SortedSet. Example #1: Scala // Sca 1 min read Scala Mutable SortedSet map() method In Scala mutable collections, map() method is utilized to build a new SortedSet by applying a function to all elements of this SortedSet. Method Definition: def map[B](f: (A) => B): mutable.SortedSet[B] Return Type: It returns a new SortedSet containing all the elements after applying the given f 1 min read Scala mutable SortedSet &() method In Scala mutable collection, &() method is utilized to create a new SortedSet consisting of all elements that are present in both the given SortedSets. Method Definition: def &(that: SortedSet[A]): SortedSet[A] Return Type: It returns a new SortedSet consisting of all elements that are prese 1 min read Scala mutable SortedSet &~() method In Scala mutable collection &~() method is utilized to create a new SortedSet consisting of elements after the difference between two given SortedSets. Method Definition: def &~(that: SortedSet[A]): SortedSet[A] Return Type: It returns a TreeSet consisting of elements after the difference be 1 min read Scala Mutable SortedSet +() method In Scala mutable collections, +() method is utilized to create a new SortedSet with an additional element unless the element is already present. Method Definition: def +(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with an additional element unless the element is already present. E 1 min read Like