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 Swift Basics (retired) Collections Modifying an Array

Help!

it looks fine but it keeps saying your todo variable has the wrong value in it ? what does that mean

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

2 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello :

When using the append method, you should only add one item at a time.

Now if you want to add one or more items to the array, you can use the += operator.

todo += ["Answer questions","Master Swift","Create an app"]

Keep going, it gets better :)

Hi Thank you so much I'l try that now hahahaahaa I Hope so! X

Since you want to add two items to the array I would use the addition assignment operator (+=). This is used if you want to add more than one compatible item to the array.

Try the code below:

var todo = ["Learn Swift", "Build App", "Deploy App"] todo =+["Debug App", "Fix bugs"]

Note that you use brackets with the addition assignment operator and not parenthesis. Hope this helps, Mindy

Thank you I'll try it now XXX