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 Collections and Control Flow Introduction to Collections Working With Arrays

Caleb Young
Caleb Young
711 Points

Am I putting this in right?

The question is asking me to remove index 5, which is 15, yet it is still telling me that I am wrong?

array.swift
// Enter your code below
var arrayOfInts = [1,9,8,90,76,15]

arrayOfInts.append(40)

arrayOfInts = arrayOfInts + [98]

arrayOfInts [4] = 76

let value = 76

arrayOfInts.remove(at: 5)

let discardedValue = 15 

1 Answer

Heidi Puk Hermann
Heidi Puk Hermann
33,366 Points

You are actually pretty close. instead of assigning 15 to the constant discardedValue, you should assign the removed value directly to the constant. Your code will look like this:

let discardedValue = arrayOfInts.remove(at: /*put your index number here*/)