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 trialLuke Tigard
Courses Plus Student 1,879 PointsI am very confused on how to assign this to the constant "value" my code in Xcode works... but not on the challenge,
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7)
[1,2,3,4,5,6,7] + [8]
arrayOfInts[4]
let firstValue = arrayOfInts[4]
// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7)
[1,2,3,4,5,6,7] + [8]
arrayOfInts[4]
let firstValuealue = arrayOfInts[4]
2 Answers
Jeff McDivitt
23,970 Pointsvar arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7)
arrayOfInts += [8]
let value = arrayOfInts[4]
let discardedValue = arrayOfInts.remove(at: 5)
Kapil Soni
2,612 PointsarrayOfInts "=+" ???
or arrayOfInts + [8]
Kapil Soni
2,612 Pointsvar arrayOfInts: [Int] = [1,2,3,4,5,6]
arrayOfInts.append(7)
arrayOfInts + [8]
let value = arrayOfInts[4]
let discardValue = arrayOfInts.remove(at: 5)
Kapil Soni
2,612 PointsKapil Soni
2,612 PointsMy Friend, you don't need to repeat the whole array, rather just mention the constant name to which you assigned the array. eg:- " [1,2,3,4,5,6,7] + [8] " this is a wrong way of doing things when you already assigned the list of numbers to constant arrayOfInts then you can simply use that. Xcode doesn't find error because there is nothing wrong in it but practically in the development environment you are just writing the number into an array without the assignment. "arrayOfInts + [8]" this is correct