Scala Queue ++:() method with example Last Updated : 24 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The ++:() method is utilized to return a new queue with all the elements of the queue appended at the front of another queue. Method Definition: def ++:[B >: A](prefix: IterableOnce[B]): Queue[B] Return Type: It returns a new queue with all the elements of the queue appended at the front of another queue. Example #1: Scala // Scala program of ++:() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue(1, 2, 3, 4, 5) val q2 = Queue(11, 12, 13, 14, 15) // Applying ++:() method val result = q1.++:(q2) // Display output print(result) } } Output: Queue(11, 12, 13, 14, 15, 1, 2, 3, 4, 5) Example #2: Scala // Scala program of ++:() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue("for", "geeks") val q2 = Queue("geeks") // Applying ++:() method val result = q1.++:(q2) // Display output print(result) } } Output: Queue(geeks, for, geeks) Comment More infoAdvertise with us Next Article Scala Queue ++:() method with example rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Scala Queue :+() method with example The :+() method is utilized to return a new queue with an element added at the back of the given queue. Method Definition: def:+[B >: A](elem: B): Queue[B] Return Type: It returns a new queue with an element added at the back of the given queue. Example #1: Scala // Scala program of :+() // metho 1 min read Scala Queue +:() method with example The +:() method is utilized to return a new queue with an element added at the front of the given queue. Method Definition: def +:[B >: A](elem: B): Queue[B] Return Type: It returns a new queue with an element added at the front of the given queue. Example #1: Scala // Scala program of +:() // me 1 min read Scala Queue +=:() method with example The +=:() method is utilized to add an element at the front of a queue. Method Definition: def +=:(elem: A): Queue.this.type Return Type: It returns the given queue with an element added at its front. Example #1: Scala // Scala program of +=:() // method // Import Queue import scala.collection.mutab 1 min read Scala Queue +=() method with example The +=() method is utilized to add an element at the back of a given queue. Method Definition: def +=(elem: A): Queue.this.type Return Type: It returns the given queue with an element added at its back. Example #1: Scala // Scala program of +=() // method // Import Queue import scala.collection.muta 1 min read Scala Queue ++() method with example The ++() method is utilized to return a new queue with all the elements of the queue appended at the back of another queue. Method Definition: def ++[B >: A](suffix: IterableOnce[B]): Queue[B] Return Type: It return a new queue with all the elements of the queue appended at the back of another qu 1 min read Scala Queue ++=() method with example The ++=() method is utilized to add element of a queue at the back of another queue. Method Definition: def ++=(xs: IterableOnce[A]): Queue.this.type Return Type: It returns the given queue with elements of another queue added at its end. Example #1: Scala // Scala program of ++=() // method // Impo 1 min read Scala Queue sum() method with example The sum() method is utilized to return the sum of all the elements of the queue. Method Definition: def sum: A Return Type: It returns the sum of all the elements of the queue. Example #1: Scala // Scala program of sum() // method // Import Queue import scala.collection.mutable._ // Creating object 1 min read Scala Set +() method with example The +() method is utilized to create a new set with an additional element unless the element is already present. Method Definition: def +(elem: A): Set[A] Return Type: It returns a new set with an additional element unless the element is already present. Example #1: Scala // Scala program of +() // 1 min read Scala Set ++() method with example 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 new set containing elements of both the sets. Example #1: Scala // Scala program of ++() // method // Creating object object GfG { // Main method def main(args 1 min read Scala Set -() method with example 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 Type: It returns a new set with a given element removed from the set. Example #1: Scala // Scala program of -() // method // Creating object object GfG { // Mai 1 min read Like