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

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

I was able to remove the third item todo.removeAtIndex(2) but not sure what is meant by ...and assign it to a constant named Item..

this is my thought process..?

let todo(2) = item

thoughts????

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

2 Answers

I figured it out. Finished the section...

let item = "Deploy App" todo.insert("Learn iOS", atIndex: 1)

Paul O'Sullivan
Paul O'Sullivan
1,457 Points

Hi,

Use removeAtIndex and assign the item being removed as a constant that you declare as "item".
So from your example ....

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

//remove 3rd in array and assign as constant "item"
let item = todo.removeAtIndex(2)

//check value of item
item

Thanks Paul