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

Ricardo Forrest
Ricardo Forrest
1,461 Points

Having trouble appending team to array

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

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

3 Answers

You can only use append one element at a time. So you can either write two append statements or use the += operator to add both elements at once. Use square brackets for the += and normal parentheses for the append method.

Hope that helps!

Steve.

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

or

todo.append("Debug App")
todo.append("Fix Bugs")
Wallace Pei
Wallace Pei
6,719 Points

no semi-colons.

Ricardo Forrest
Ricardo Forrest
1,461 Points

Thanks a lot, really helped a lot.m:)

Josh Bradford
Josh Bradford
9,935 Points

Do not place the period at the end of your append method. ("Fix Bugs" . <--- ) I believe that should help.