When to use Array and when to use List

Array

Never
Well, if you need to optimize the performance of some function and you know how to properly use an array to do that then go ahead. But other than such a niche case you should never use Array, they are mutable, invariant, don’t have a proper toString, their equals is by reference instead of by-value, they are not real collections but a primitive of the JVM / JS / LLVM runtime.

List

While learning can be a good default collection. Other collections like Vector or just using abstract Seq may be good options while learning.

After learning List is still a great collection if all you need is linear iteration, (tail) recursion, and you are okay with building it thought constant pre-pends and a final reverse (if required)
For example, I personally use List 99% of the time.

Vector

Good for having an okey-ish performance for most operations.
Very good for constantly appending data, although cats.data.Chain is better for data, but has the disadvantage of being outside of the stdlib.

ArraySeq

The best collection if all you need is fast access by index.
Also, it is very efficient to create when you use methods like tabulate

3 Likes