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 trialKawal Oberoi
6,429 PointsWhere did I got wrong. OMG!! ; - ;
Please help! ; - ;
// Enter your code below
class Shape(){
var numberOfSides: Int
init(numberOfSides: Int){
self.numberOfSides = numberOfSides
}
}
let someShape = Shape()
Greg Kaleka
39,021 Pointssugabelly, you've got a capitalization error on the numberOfSides property. Tiny typos can cause cause big headaches!
1 Answer
Greg Kaleka
39,021 PointsHi Kawal,
Two small issues with your code:
- When declaring a class, you don't need opening and closing parentheses. This isn't a function, and we're not creating a class instance.
- When you do create an instance of Shape, you have to use the initializer you just created, which takes one argument - an integer for the number of sides.
I think you can take it from here!
Cheers
-Greg
Kawal Oberoi
6,429 PointsFixed! Yay!
But Seriously man, Object Oriented Programming is pretty confusing. Especially when we are declaring so many values etc. There should be some analogy to make it easier.
Greg Kaleka
39,021 PointsIt's hard to wrap your head around, for sure! You'll get it though. Keep working on it!
sugabelly
2,524 Pointssugabelly
2,524 PointsI'm having the same problem. What's wrong with my code?