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:
import scala.collection.mutable. _
object GfG
{
def main(args : Array[String])
{
val q 1 = Queue( 3 , 4 , 5 )
val q 2 = Queue( 1 , 2 )
q 2 .++ = (q 1 )
print(q 2 )
}
}
|
Output:
Queue(1, 2, 3, 4, 5)
Example #2:
import scala.collection.mutable. _
object GfG
{
def main(args : Array[String])
{
val q 1 = Queue( "for" , "geeks" )
val q 2 = Queue( "geeks" )
q 2 .++ = (q 1 )
print(q 2 )
}
}
|
Output:
Queue(geeks, for, geeks)
Last Updated :
18 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...