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

why you can not write todo.append("Debug App" , "Fix Bugs") ?

the correct answer is : var todo = ["Learn Swift", "Build App", "Deploy App"] todo.append("Debug App") todo.append("Fix Bugs") but why U can not answer this way

todo.append("Debug App", "Fix Bugs")

2 Answers

petri foxx ,

it has to do with the way the member methods (function in a Data Type like "Array") take arguments. in this case, the Array method "append" can only take one argument, not two, as you ask about [todo.append("Debug App", "Fix Bugs") returns an error in the Xcode compiler or playground: ! Extra argument in call - meaning the call only expects one argument and doesn't know what to do when you give it two, as in your example].

you could do it this way:

todo.append("\"Debug App\", \"Fix Bugs\"")

^^^^ by using the \" escape references for the quote marks, this makes everything one string you are adding on, not two arguments.

i hope this makes it clear to you.

best,

ā€” faddah portland, oregon, u.s.a.

thx mate. now I have it clear that append command does NOT take 2 arguments! (even I think it should) maybe in next version!!!