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

Matt Fiji
Matt Fiji
523 Points

Retrieving the 5th item of an array

I was able to find the 5th item on Xcode but on here I am getting an error. Help please :)

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

2 Answers

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

You did brilliantly actually. The problem is that you missed part of the instructions where it says to get the 5th element (which you did) and assign it to a constant named value: Here's the single line that needs to be changed:

let value = arrayOfInts[4]

By the way, did I mention challenges are picky? :)

Matt Fiji
Matt Fiji
523 Points

Thank You! so much!

Matt Fiji
Matt Fiji
523 Points

OHHH a constant named "value".. that totally went over my head! Thank you so much!!!