Related Articles

Related Articles

Scala Queue ++=() method with example
  • Last Updated : 18 Oct, 2019

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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(3, 4, 5
          
        val q2 = Queue(1, 2
          
        // Applying ++=() method 
        q2.++=(q1
              
        // Display output
        print(q2)   
          
    

chevron_right


Output:

Queue(1, 2, 3, 4, 5)

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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 
        q2.++=(q1
              
        // Display output
        print(q2)   
          
    

chevron_right


Output:

Queue(geeks, for, geeks)



My Personal Notes arrow_drop_up
Recommended Articles
Page :