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 Instances of Classes

Kyle Lambert
Kyle Lambert
1,969 Points

Challenge Task 1

Can someone please explain what I'm doing wrong here.. I keep getting a compile error. Something to do with assigning a property to itself. Thanks

classes.swift
// Enter your code below
class Shape {
    var numberOfSides: Int

    init(sides numberOfSide: Int) {
    self.numberOfSides = numberOfSides
    }
}
let someShape = Shape(sides: 3)

2 Answers

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Kyle,

you almost got it right! The only problem is a typo: You called the parameter in the init method numberOfSide instead of numberOfSides . If you fix this it should work.

I hope that helps! :)

Kyle Lambert
Kyle Lambert
1,969 Points

Ahh I see, thank you :)