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

iOS Build a Simple iPhone App with Swift Getting Started with Xcode A Swift Recap

Fedor Andreev
Fedor Andreev
11,203 Points

What is the difference between these Arrays?

var xyz = ["x","y","z"]

var xyz = ["x"],["y"],["z"]

getting_started.swift
let bestSmartphone = "iPhone"
var favoriteSports: [String] = ["football"], ["basketball"], ["tennis"]

2 Answers

Enrique Munguía
Enrique Munguía
14,311 Points
let 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
Fedor Andreev
11,203 Points

So this example Array

var xyz = ["x"],["y"],["z"]

Is incorrect? All the items must be inside the bracket?