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 Classes High Level Overview

Kevin Bullis
Kevin Bullis
13,770 Points

Should it read "surroundingPoints" instead of "availablePoints" at 0:40 in the video?

I'm guessing there's a typo.

1 Answer

David Leininger
David Leininger
13,034 Points

Yes this should be "surroundingPoints". You should be able to see that in struct Point { } in his project files or yours if you were following along.

struct Point { // indicate the x and y work together... they are a unit
    let x: Int
    let y: Int

    init(x: Int, y: Int) {
        self.x = x // self.x means the stored property x
        self.y = y
    }

    func surroundingPoints(withRange range: Int = 1) -> [Point] {
        var results: [Point] = []
        for xCoord in (x-range)...(x+range){
            for yCoord in (y-range)...(y+range) {
                let coordinatePoint = Point(x: xCoord, y: yCoord)
                results.append(coordinatePoint)
            }
        }
        return results
    }
}