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

Brian Patterson
Brian Patterson
19,588 Points

Another badly worded question.

I understand arrays but this challenge is really badly put. I don't understand why it keeps telling me that this wrong. // Enter your code below var arrayOfInts: [Int] = [1,2,3,4,55,78]

arrayOfInts.append(44)

arrayOfInts += [55]

let seventyEight = arrayOfInts[5]

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

arrayOfInts.append(44)

arrayOfInts += [55]

let seventyEight = arrayOfInts[5]

2 Answers

Christian Kroul
Christian Kroul
9,849 Points

Correct Code

var arrayOfInts = [1,2,3,4,5,6]

arrayOfInts.append(44)

arrayOfInts += [7]

let value = arrayOfInts[4]

let discardedValue = arrayOfInts.removeAtIndex(5)

I don't get why you need to assign "value" and "discardedValue" wouldn't arrayOfInts.removeAtIndex(5) be all that you need to do type?

Christian Kroul
Christian Kroul
9,849 Points

It does nothing really, just that's how the code challenge wants you to do