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

Code reads from array in Xcode but online editor says I'm doing it wrong ?

When reading the fifth item from the Array using "let fifthTask = arrayOfInts[5]", it says "Make sure you're assigning the result of retrieving an item from the array to a constant named value" while I'm pretty sure this is correct...

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

arrayOfInts.append(666)

arrayOfInts += [9]

let fifthItem = arrayOfInts[4]

2 Answers

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey there,

your code is actually perfectly fine, good job! :) The only problem is that the constant you're saving the value of the fifth item of the array in should be called value instead of fifthItem .

Like so:

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

arrayOfInts.append(666)

arrayOfInts += [9]

let value = arrayOfInts[4]

I hope that helps! :)

I've always had problems with reading the questions :'(

Thanks for the quick reply ! :D

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Your question sort of answers itself. Take a look at this line: Make sure you're assigning the result of retrieving an item from the array to a constant named value. Challenges are picky... really picky. Here's the correct line you need:

let value = arrayOfInts[4]