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

Difference between todo.append and +=

I do not capture the difference between todo.append and +=

Thank you Greg

3 Answers

Logan R
Logan R
22,989 Points

They do essentially the same thing in this case, except you can't use .append on all things.

Say you had x = 5 and you wanted to add 5 to it, you could do x += 5, you couldn't do x.append(5) though.

That's clear. Thanks Logan

Tingting Gu
Tingting Gu
10,760 Points

I think we can also use .append() in Logan's case. I used .append(5) and it returned [5,5].