Scala List splitAt() method with example Last Updated : 13 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The splitAt() method belongs to the value member of the class List. It is utilized to split the given list into a prefix/suffix pair at a stated position. Method Definition: def splitAt(n: Int): (List[A], List[A]) Where, n is the position at which we need to split. Return Type: It returns a pair of lists consisting of the first n elements of this list, and the other elements. Example #1: Scala // Scala program of splitAt() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a List val list = List("a", "b", "c", "d", "e", "f") // Applying splitAt method val result = list.splitAt(3) // Displays output println(result) } } Output: (List(a, b, c), List(d, e, f)) Example #2: Scala // Scala program of splitAt() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a List val list = List(1, 2, 3, 4, 5, 6, 7) // Applying splitAt method val result = list.splitAt(4) // Displays output println(result) } } Output: (List(1, 2, 3, 4), List(5, 6, 7)) Comment More infoAdvertise with us Next Article Scala List splitAt() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-list Similar Reads Scala List take() method with example The take() method belongs to the value member of the class List. It is utilized to take the first n elements from the list. Method Definition: deftake(n: Int): List[A] Where, n is the number of elements to be taken from the list. Return Type:It returns a list containing only the first n elements fro 1 min read Scala Set splitAt() method with example 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]) Where, n is the position at which we need to split. Return Type: It returns a pair of sets consisting of the first n elements of this set, 1 min read Scala Queue splitAt() method with example The splitAt() method is utilized to split the given queue into a prefix/suffix pair of queues at a stated position. Method Definition: def splitAt(n: Int): (Queue[A], Queue[A]) Where, n is the position at which we need to split. Return Type: It returns a pair of queues consisting of the first n elem 1 min read Scala Stack splitAt() method with example In Scala Stack class, the splitAt() method is utilized to split the given stack into a prefix/suffix pair of stacks at a stated position. Method Definition: def splitAt(n: Int): (Stack[A], Stack[A]) Return Type: It returns a pair of stacks consisting of the first n elements of this stack, and the ot 1 min read Scala TreeSet splitAt() method with example The splitAt() method is utilized to split the given TreeSet into a prefix/suffix pair of TreeSet at a stated position. Method Definition: def splitAt(n: Int): (TreeSet[A], TreeSet[A]) Where, n is the position at which we need to split. Return Type: It returns a pair of TreeSet consisting of the firs 1 min read Like