Scala List +() operator with example Last Updated : 26 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The +() operator in Scala is utilized to append an element to the list. Method Definition: def +(elem: A): List[A] Return Type: It returns a list of the stated elements after appending it to an another element. Example #1: Scala // Scala program of +() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(1, 2, 3) // Applying + operator val res = m1.+("10") // Displays output println(res) } } Output: List(1, 2, 3)10 Example #2: Scala // Scala program of +() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List() // Applying + operator val res = m1.+("10") // Displays output println(res) } } Output: List()10 Comment More infoAdvertise with us Next Article Scala List +() operator with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-list Similar Reads Scala List :::() operator with example The :::() operator in Scala is utilized to join the List in the argument to the another List. Method Definition: def :::(prefix: List[A]): List[A] Return Type: It returns a list after joining one list to the another one. Example #1: Scala // Scala program of :::() // method // Creating object object 1 min read Scala List ::() operator with example The ::() operator in Scala is utilized to add an element to the beginning of the List. Method Definition: def ::(x: A): List[A] Return Type: It returns the stated list after adding an element to the beginning of it. Example #1: Scala // Scala program of ::() // method // Creating object object GfG { 1 min read Scala List sum() method with example The sum() method is utilized to add all the elements of the stated list. Method Definition: def sum(num: math.Numeric[B]): B Return Type: It returns the sum of all the elements of the list. Example #1: Scala // Scala program of sum() // method // Creating object object GfG { // Main method def main( 1 min read Scala ListSet sum() method with example In Scala ListSet, sum() method is utilized to add all the elements of the stated listSet. Method Definition: def sum(num: math.Numeric[B]): B Return Type: It returns the sum of all the elements of the listSet. Example 1: Scala // Scala program of sum() // method import scala.collection.immutable._ / 1 min read Scala Iterator sum() method with example The sum() method belongs to the concrete value members of the class AbstractIterator. It is defined in the classes TraversableOnce and GenTraversableOnce. It adds the elements of the stated collection. Method Definition: def sum: A Return Type: It returns the sum of all the elements in the stated it 1 min read Like