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

Compiler error in Treehouse but not Xcode

So this code seemed to be following directions but it keeps saying compiler error no matter what... I put it into Xcode to see if the compiler error showed up there, but it did not. What might I do here besides skip the challenge?

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

2 Answers

Interesting that you don't get an error in Xcode. You are close though. The challenge is looking for you to assign the value in the array at the 5th index to a constant named value.

You clearly know how to create a constant named value and assign something to it:

let value = 5

And you correctly grabbed the 5th item in the array


Now, just assign the arrayOfInts[4] to the constant let value = and get ride of the number 5

let value = arrayOfInts[4]
Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Hi Parker I looked at the code you provided if it was for the third part of this challenge you need to assign the constant value to the call of the 5th item in the arrayOfInts

let example = testArray[3]