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

kevin chang
kevin chang
408 Points

I don't get it help me please

i done get it i put it in right

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

1 Answer

Nathan F.
Nathan F.
30,773 Points

Since you appended two additional items, Debug App and Fix Bugs, your array now looks like this

[0] -> "Learn Swift"
[1] -> "Build App"
[2] -> "Deploy App"
[3] -> "Debug App"
[4] -> "Fix Bugs"

Because it wants you to remove "Deploy App", you can't use removeLast, because "Fix Bugs" is the last value. You should use the method "removeAtIndex" instead.