why not `val list = ["a", "b", "c"]`
# random
s
why not
val list = ["a", "b", "c"]
k
because that ties the syntax to a concrete implementation of
List
but some would like to be able to have different
Array
,
Set
or other collections.
s
Oh I didn't realize.
d
Swift solves this by having Array as a default so @Sola ’s example would work.
But it is also possible to coerce to any
ArrayLiteralConvertible
collection.
k
@darkmoon_uk it gets tricky. It's easy to write buggy code with that kind of default. If it were to exist at all (which I don't really deem important), I'd advocate for no explicits.
d
@kingsley I don’t disagree… when I write Swift I always make it explicit for the same reason.
You know Apple, trying to be all minimal.
😂 1
s
and how would you differentiate whateverCollection from whateverMutableCollection ? 😛