Arrays: Why doesn't this empty array work?

I’m currently learning Arrays, and I’d like to ask why the following code does not work:

//Trying to create an empty array here:
var thisOtherArray = Array("")

print(thisOtherArray)

//Trying to append “Fifi” to the above array.
thisOtherArray += [“Fifi”]

Why doesn’t this work?

Do I have to instead write it as:
var thisOtherArray: [String] = [" "]

I assumed the first block of code would work because the following code DOES work:

var arrayOfValues = Array(10…19)

Please let me know, thank you!

It doesn’t work because this:

doesn’t create an array.

I assumed the first block of code would work because the following code DOES work:

But those two lines aren’t similar at all, so I’m not sure why the latter would lead you to think the former would work. In the latter line, you are creating an array from a range of Ints; in the first line, you are trying to print the value of an array. Two completely different things.

These lines:

var thisOtherArray: [String] = [" "]
var arrayOfValues = Array(10…19)

do create arrays. (Though note that neither one is an empty array, as they both are created containing values.)

To create an empty String array, you need to use one of these approaches:

var thisOtherArray: [String] = []
var thisOtherArray = Array<String>()

Thank you for this. I noticed that I actually somehow didn’t include the line of code my question was about! (I.e., the line of code in which I first attempted to create an array that, coincidentally, didn’t work anyway).

I believe that your second propoosed line of code was the one that I was trying to remember and mistyped anyway, apparently. Thank you for your help, much appreciated. :slight_smile: