The following:
var emptyArray = [String]();
What do I need the parentheses () for? [String] says, that the array accepts strings only. But why do I have to put the () there?
The following:
What do I need the parentheses () for? [String] says, that the array accepts strings only. But why do I have to put the () there? |
||||
Two things are true in Swift:
Combine the two and you get |
|||||||||
|
String
. The round things afterward are parentheses, or just "parens" if you're being informal. – Mason Wheeler 12 hours ago[String]
denotes a type: array of strings, but you're not trying to assign a type toemptyArray
; you're trying to assign an instance of that type, which is where the parens come in. (Note: if any actual Swift devs see this and I'm way off, bear in mind the above: I've never used Swift. Just making an educated guess here.) – Mason Wheeler 12 hours ago