Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Collections Modifying an Array

John Moron
John Moron
1,658 Points

We need to append a few more items to our todo array. Append the following strings: "Debug App", "Fix Bugs".

What am I doing wrong?

var todo = ["Learn Swift","Build App","Deploy App"]
todo.append: [String] = ["Debug App","Fix Bugs"]

2 Answers

William Li
William Li
Courses Plus Student 26,865 Points

Hi, John Moron , if you wanna append everything in one line, then change your last line to

todo += ["Debug App","Fix Bugs"]

with +=, you can merge two list into one.

Logan R
Logan R
22,989 Points

There are a few different ways to do this but one you can try is to append them one at a time.

var todo = ["Learn Swift","Build App","Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")

I tried doing it this way, Although correct, it doesn't appear to want this answer