Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Tyler Dotson
Courses Plus Student 1,740 Pointswhy does this not work?
why does numberOfSides not work?
// Enter your code below
class Shape {
var numberOfSides: Int
init(sides: Int) {
self.numberOfSides = numberOfSides
}
}
let someShape = Shape()
3 Answers

David Papandrew
8,386 PointsIt doesn't work because:
1) Your init method should assign the init method's sides parameter to self.numberOfSides (right now you are assigning an undeclared object, numberOfSides)
2) When creating the someShape constant, the init method should take an argument
Here's the corrected code:
// Enter your code below
class Shape {
var numberOfSides: Int
init(sides: Int) {
self.numberOfSides = sides
}
}
let someShape = Shape(sides: 4)

NIKOLA RUSEV
5,293 Pointshi david
i solve the challange but just want to ask you is it matter the name of argument in init? becaouse i solve with init(numberOfSides: Int) { self.numberOfSides = numberOfSides my question is not just for this challenge i mean further in codinig is this correct?

David Papandrew
8,386 PointsHi Nikola,
No the parameter name can be whatever you want. This is not a problem. Only issue is that the Treehouse challenges may want variables/constants and parameters with very specific names at times. In those cases, you will want to follow the instructions exactly or you might not pass the challenge (even though it will work in Playgrounds).

NIKOLA RUSEV
5,293 Pointsthanks