Accepted answer

You're looking for a collection which maintains order. Any collection that extends seq maintains the order in which elements were added.

[scaladocs] Sequences have two principal subtraits, IndexedSeq and LinearSeq, which give different guarantees for performance. An IndexedSeq provides fast random-access of elements and a fast length operation. A LinearSeq provides fast access only to the first element via head, but also has a fast tail operation

List extends LinearSeq, while Vector extends IndexedSeq

Choosing between these will depend on how you wish to access the data, and operations you wish to performs on the data.

Related Query

More Query from same tag