In Scala, scala.collection.mutable implements Stack data structure. The :+ method is used to create a copy of this stack with an element appended.
Method Definition – def :+(elem: A)
Returns – a new stack consisting of all elements of this stack followed by elem.
List(11, 12, 13, 14, 15, 100)
Stack(Geeks, For, Stack(1, 2, 3))
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.