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

Jeremy Stewart
Jeremy Stewart
1,545 Points

Don't understand quiz answer

The quiz question asks me to assign a constant and retrieve the 5th number from the array. The code i've entered does this. What am I doing wrong?

arrays.swift
// Enter your code below

var arrayOfInts = [100,200,300,400,500,600]

arrayOfInts.append(700)

arrayOfInts += [800]

let numberFive = arrayOfInts[4]

3 Answers

Alexander Smith
Alexander Smith
10,476 Points

where you have

let numberFive = arrayOfInts[4]

they just wanted it to be named value. Everything else is correct

Sidney Swenson
Sidney Swenson
2,429 Points

Correct code would just be

let value = arrayOfInts[4]

Jeremy Stewart
Jeremy Stewart
1,545 Points

ok thx.

it would be so helpful if you could reveal answers on quizzes. It really stops the learning when the question / answer subtleties are so minimal.