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

I am using the append method but its not working for some odd reason please help

if u helped me then u r da BEST!!!!!!!!!!!!!!!!!!!!

thx

array.swift
// Enter your code below
var arrayOfInts = [1,5,3,7,]
arrayOfInts.append(1,3)

1 Answer

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Hi Rico, in your array I think its missing a few values they want you to have 6 items in your array. In the next part of this challenge you have to append items to the array the two different ways they showed you. The first is the append method the second is by using the insert method. You have to use dot notation after the name of the array to access them. I would recommend loading code challenges into Xcode instead of only solving them here. It gives you good clues as you type. For the code above you are trying to append two values and if you type this into Xcode it'll give you an error "extra argument in call". So only append one value at a time

var example = [23,4,6,3,5,9]

example.append(43)

// nameOfArray.append( a value that is the same type as the array) 

hope this helps !