Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Collections and Control Flow Introduction to Collections Working With Arrays

Nigel Matheson
Nigel Matheson
Courses Plus Student 1,166 Points

My code is not working?

this is not working and it is driving me crazy

// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]

arrayOfInts.append (7)
arrayOfInts = [1,2,3,4,5,6,7] + [8]

arrayOfInts.remove (at:4)

Let value = arrayOfInts [4]

2 Answers

Hi Nigel,

You got most of that spot on.

For the second task, I don't think it was expecting you to recreate the initial array. The concatentate could look something like:

arrayOfInts = arrayOfInts + [8]

The third task wants you to retrieve the value at index 4 and store it in a constant called value. You've removed the value then tried to store the [4] in value - but you've also used a capital L on let - so, don't remove the element (delete that line) then correct the capitalisation:

let value = arrayOfInts[4]

The last task wants you to remove an element - I'll leave that task with you.


No problem! :+1: