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 Object-Oriented Swift 2.0 Complex Data Structures Methods

Array of Point

When you say you can only append point instances to the array of type Point. Does that mean any variable or constant instantiated inside of the struct Point?

1 Answer

It means that if you have an array of type custom struct Point like so:

var pointArray: [Point] = []

You can fill it with your point struct. So if your point struct was initiated as so:

struct Point {
var name: String
var number: Int

init(name: String, number: Int) {
self.name = name
self.number = number
}

}

You could fill the point array like so:

let firstPoint = Point(name: "Ian", number: 22)
pointArray.append(firstPoint)

or of course just in the original declaration of the array.