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 trialFedor Andreev
11,203 PointsWhat is the difference between these Arrays?
var xyz = ["x","y","z"]
var xyz = ["x"],["y"],["z"]
let bestSmartphone = "iPhone"
var favoriteSports: [String] = ["football"], ["basketball"], ["tennis"]
2 Answers
Enrique Munguía
14,311 Pointslet bestSmartphone = "iPhone"
var favoriteSports: [String] = ["football"], ["basketball"], ["tennis"]
The second line gives a compilation error, the array of strings is not declared correctly
var favoriteSports: [String] = ["football", "basketball", "tennis"]
Individual items within the array must be separated by commas
Fedor Andreev
11,203 PointsSo this example Array
var xyz = ["x"],["y"],["z"]
Is incorrect? All the items must be inside the bracket?