A set is a collection that only contains unique items. In Scala, both mutable and immutable sets are available. The mutable set is those set… Read More
Tag Archives: Scala-Set
The takeRight() method is utilized to return a set consisting of last ‘n’ elements of the set. Method Definition: def takeRight(n: Int):Set[A] Where ‘n’ is… Read More
The last() method is utilized to return the last element of the set. Method Definition: def last: A Return Type: It returns the last element… Read More
The contains() method is utilized to check if an element is present in the set of not. Method Definition: def contains(elem: A): Boolean Return Type:… Read More
The take() method is utilized to return a set consisting of first ‘n’ elements of the set. Method Definition: def take(n: Int): Set[A] Where ‘n’… Read More
The -() method is utilized to creates a new set with a given element removed from the set. Method Definition: def -(elem: A): Set[A] Return… Read More
The toArray() is utilized to return an array consisting of all the elements of the set. Method Definition: def toArray: Array[A] Return Type: It returns… Read More
The +() method is utilized to create a new set with an additional element unless the element is already present. Method Definition: def +(elem: A):… Read More
The ++() method is utilized to add elements of one set to another set. Method Definition: def ++(elems: A): Set[A] Return Type: It returns a… Read More
The splitAt() method is utilized to split the given set into a prefix/suffix pair at a stated position. Method Definition: def splitAt(n: Int): (Set[A], Set[A])… Read More
The max() method is utilized to find the smallest element of all the elements in the stated list. Method Definition: def min: A Return Type:… Read More
The subsetOf() method is utilized to test if a set is a subset of another set. Method Definition: def subsetOf(that: Set[A]): Boolean Return Type: It… Read More
The max() method is utilized to find the largest element of all the elements in the set. Method Definition: def max: A Return Type: It… Read More
The sum() method is utilized to find the sum of all the elements of the set. Method Definition: def sum: A Return Type: It returns… Read More
The &~() method is utilized to create a new set consisting of elements after the difference between two given sets. Method Definition: def &~(that: Set[A]):… Read More