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

Amir Shahabnia
Amir Shahabnia
29,310 Points

Can someone help me what is wrong with my code?

I keep receiving error for my code but I don't know why, can someone please explain what is wrong here?

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

arrayOfInts.append(13)
arrayOfInts += [23]

let fifthItem = arrayOfInts[4]
Jose Patarroyo
Jose Patarroyo
2,953 Points

I copied pasted your code into Xcode and it compiled with no errors...Did you get an error on Xcode? what does it say?

Amir Shahabnia
Amir Shahabnia
29,310 Points

It's on a challenge task (part 3/4). I receive this "Make sure you're assigning the result of retrieving an item from the array to a constant named value".

I think it's bug, isn't it?

2 Answers

Jose Patarroyo
Jose Patarroyo
2,953 Points

Im not sure but I believe the error is caused just because the compiler expects a constant called "value" and I don't see it in your code. I'm not sure where exactly is the challenge you are taking (maybe you can provide more information of where in the track is this task located), but I believe it will work if you change the name of your fifthElement constant to "value"

Amir Shahabnia
Amir Shahabnia
29,310 Points

You are absolutely right, I don't know why I didn't see that. I did work!! Thanks! Also I'm a noob here and I thought the section of the challenge would be seen here, but it's all solved now.