Yes, when the options are to solve none or just some of the requirements, I do think that an imperfect solution is preferred. It’s called pragmatic
The reason for choosing Arrays over List
is the same as vararg
- it’s the simplest data type which represents the input. If you consider where collection literals are used in practice (arrayOf
, listOf
, etc.), it’s usually in short scripts, or sample data in test code. In either case, all you need is something which can be iterated over. Unless you need to provide a specific collection type/interface for the API under test, in which case your code is clearer with an explicit constructor.
Another way of looking at it is that collection literals are most useful in circumstances where the type of the collection doesn’t actually matter.