Why aren't plus/minus operators defined on `Array&...
# stdlib
m
Why aren't plus/minus operators defined on
Array<T>
?
i
And we do not provide
Array.minus
because it's required to know in advance the size of the result array to allocate.
m
Ahh. Forgot
Array
is invariant. Was trying to plus Array<SubClass> + List<SuperClass>.
Makes sense with minus.
.toList()
solves all the problems...
b
If order doesn't matter,
Set
might be better-suited
m
Thanks. My lists are generally short, so I don't care too much about micro-optimizations for now. And don't get me started on how I found
list - element != list - listOf(element)
😉
v
^^ good puzzler right there