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.

iOS Object-Oriented Swift 2.0 Classes Instances of Classes

William Liu
William Liu
1,516 Points

Can someone give me the solution to Task 1, please?

I simply can't figure out what I need to add or change in order to finish this task. Thank's in advance!

// Enter your code below
class Shape {
var numberOfSides: Int 
init(numberOfSides: Int){
self.numberOfSides = numberOfSides
let someShape = Shape()

2 Answers

Close, but you need to tell your shape how many sides it has by passing it numberOfSides:X where X is the number of sides - for example to create a 4 sided shape...

let someShape = Shape(numberOfSides:4)
William Liu
William Liu
1,516 Points

Thanks a lot, Gavin! :)

I guess I didn't know what to enter for X in (numberOfSides:X) since the task doesn't specify...

No problem. If you're happy with the answer you can mark it as correct. :) The task could've been clearer - e.g. asking you to create a square. :)