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 trialEli Hartnett
313 PointsI think the check work button is messed up. I tested in xcode what I think the question is asking, but still wrong.
I got everything correct until the last line which is to remove the 6th item in arrayOfInts and assign it to a constant named discarded value.
// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(0)
var randomArray = [7]
arrayOfInts += randomArray
let discardedValue = arrayOfInts.remove(at: 5)
1 Answer
Jason Ernsdorff
3,112 PointsIβm not sure what problem you are having but it appears that .remove takes the value from the specified slot +1. So .remove(at: 5) removes the sixth slot as you expected. This works perfectly in the latest version of Xcode and in playgrounds discarded value returns 6. If this is not what you are expecting then I guess I donβt understand your question. You know array keys start with position 0 not 1 right?