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

What's wrong with my constant?

assigning a constant named 'value' and assigning it the 5th place in the index seems pretty straight forward yet the compiler is telling me its incorrect. Looking at the video from your group and apple documentation it appears that i am writing it correctly. Is there a an error on your end or mine?

array.swift
// Enter your code below
var arrayOfInts = [0,1,2,3,4,5]
arrayOfInts.append(4)
arrayOfInts += [7]
arrayOfInts.value(4)
let value = arrayOfInts[4]

1 Answer

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

Hi there! You have one line that's causing the problem. This isn't a valid Swift statement for arrays. Remove this:

arrayOfInts.value(4)

Hope this helps! :sparkles:

I shouldn't do this while I am falling asleep anymore, thanks.