I need something to store a LIFO. No need for traversing and other functions except for push and pop.
I’ve found special class in scala collection for creating a stack. But it lacks Nil object in pattern matching and other handy scala idioms. Immutable lists suit well at first glance, they have cons for construction and for extraction and that is all needed from LIFO.
Is there any reason behind scala.collection.immutable.Stack existence? Why I should prefer to use it, what are use cases to show its benefits?
From the API documentation:
And in a little more detail:
So to answer your questions: