Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Agustin Hernandez](https://secure.gravatar.com/avatar/ea84e6636f92a71c739e4983337a3cdb?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Agustin Hernandez
2,747 PointsCreating Empty Arrays
What's the difference when declaring an empty array
// like this
var someArray: [SomeType]
// Or like this
var someArray = [SomeType]()
2 Answers
![Alex Koumparos](https://uploads.teamtreehouse.com/production/profile-photos/8418842/micro_IMG_1256__cropped_and_reduced_res_.jpg)
Alex Koumparos
Python Development Techdegree Student 36,887 PointsIn the first case:
var someArray: [SomeType]
You have declared but not initialised your array. If you wanted to use this style to declare an empty array, you would have written:
var someArray: [SomeType] = []
The second case:
var someArray = [SomeType]()
is exactly equivalent to var someArray: [SomeType] = []
. The difference is purely personal style preference.
Apple uses both in their own documentation, see here and here
![johntheofanopoulos4](https://secure.gravatar.com/avatar/31e3e8cff1e708c1c124c9d1827eb815?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
johntheofanopoulos4
iOS Development with Swift Techdegree Student 474 PointsFirst line is that you have declared your array but didn't assign anything (technically you just gave a name but no value)
Second line of code, you have named your array and assigned an empty/placeholder value in it.