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

Evan Eshel
Evan Eshel
7,002 Points

Hi, I am trying to do the challenge and it keeps on saying, "Bummer1 You need to define team let. Help me please!

Why would it want me to define item when I do not have it?

~thanks

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App", "Fix Bugs"]
todo.insert("Learn iOS", atIndex: 1)

1 Answer

Stone Preston
Stone Preston
42,016 Points

the task states: Please remove the third item ("Deploy App") and assign it to a constant named item.

according to the documentation, swift arrays have a method called removeAtIndex:

removeAtIndex(_:)

Removes the element at the given index and returns it.

so we can remove the item and assign that item that was removed to a constant in one step:

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