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 trialKevin Sanchez
484 PointsArrays and Ints
so I'm having some trouble with the concatenating part of the task in the array of ints
// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append(7)
var arrayOfInts = arrayOfInts + 8
1 Answer
Xiao Huang
5,754 PointsarrayOfInts.append(7)
-> ([Int]).append(Int)
This is correct adding an Int to [Int]
var arrayOfInts = arrayOfInts + 8
-> [Int] = [Int] + Int
But here cannot concatenate a [Int] with an Int
arrayOfInts = arrayOfInts + [8]
This could work
Giorgos Karyofyllis
21,276 PointsGiorgos Karyofyllis
21,276 PointsHi Kevin, Because you concatenate two arrays you have to include to arrays. The 8 is an integer so put the 8 inside square brackets and it would be fine!