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

Jonny H.
Jonny H.
311 Points

How do I properly "removeLast" and "removeAtIndex", etc? I am having trouble understanding the objective here.

I can’t seem to figure out what Im doing wrong here. I have basically coped line for line what the guy in the video did but I keep getting error messages like...

"You need to call the 'removeAtIndex' method on the array.”

and when I add it, I get more error messages.

Any help is much appreciated. I can usually reverse engineer things if I have the correct answer.

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]

todo.append("Debug App")

todo.append("Fix Bugs")

let item = todo.removeLast("Deploy App")

todo.removeAtIndex(2)

1 Answer

Jacob Bergdahl
Jacob Bergdahl
29,118 Points

.removeLast() likely doesn't take a parameter, since it removes the last one :) Simply remove the string parameter from it and see if it works.