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

not quite sure if I typed this out correctly?

can I please get some help with this array question

array.swift
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append ("7")
[1,2,3,4,5,6] + [7]

1 Answer

John Marley
John Marley
8,740 Points

Hello,

In appending the array, the quotation marks around the "7" mean it is a String; arrays are 'homogenous' and can only accept one type of data like Ints, Strings, Doubles etc.

// arrayOfStrings would look like ["this", "is", "a", "string"]

arrayOfInts[0,1,2,3,4,5,6,7]
arrayOfInts.append(7)

The String concatenation you've done at the bottom passes the challenge too.

I hope this helps :)