Scala Mutable SortedSet last() method Last Updated : 26 Mar, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Scala mutable collections, last() method is utilized to return the last element of the SortedSet. Method Definition: def last: A Return Type: It returns the last element of the SortedSet. Example #1: Scala // Scala program of last() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(1, 2, 3, 4) // Applying last method val result = s1.last // Display output println(result) } } Output: 4 Example #2: Scala // Scala program of last() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet("geeks", "for", "geeks", "classes") // Applying last method val result = s1.last // Display output println(result) } } Output: geeks Comment More infoAdvertise with us Next Article Scala Mutable SortedSet map() method S Shivam_k Follow Improve Article Tags : Scala Scala Scala-Method Scala mutable-sortedset Similar Reads Scala Mutable SortedSet max() method In Scala mutable collections, max() method is utilized to find the largest element of all the elements in the SortedSet. Method Definition: def max: A Return Type: It returns the largest of all the elements in the SortedSet. Example #1: Scala // Scala program of max() // method import scala.collecti 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 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 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 filter() method In Scala mutable collections, SortedSet filter() method is utilized to select all elements of the SortedSet which satisfies a stated predicate. Method Definition: def filter(p: (A) => Boolean): SortedSet[A] Return Type: It returns a TreeSet containing all the elements of the SortedSet which satis 1 min read Like